Skip to content

Data class rule: removing several cases from the scope of the inspection#1471

Merged
orchestr7 merged 8 commits intomasterfrom
bugfix/data-class-rules
Jul 25, 2022
Merged

Data class rule: removing several cases from the scope of the inspection#1471
orchestr7 merged 8 commits intomasterfrom
bugfix/data-class-rules

Conversation

@orchestr7
Copy link
Copy Markdown
Member

What's done:

  • Removed annotation, value, sealed, inline, inner classes from the scope
  • Added tests

@orchestr7 orchestr7 added this to the 1.2.2 milestone Jul 22, 2022
@orchestr7 orchestr7 linked an issue Jul 22, 2022 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 22, 2022

Codecov Report

Merging #1471 (90db394) into master (632ac74) will increase coverage by 0.02%.
The diff coverage is 80.00%.

@@             Coverage Diff              @@
##             master    #1471      +/-   ##
============================================
+ Coverage     83.25%   83.27%   +0.02%     
- Complexity     2561     2569       +8     
============================================
  Files           110      110              
  Lines          7661     7661              
  Branches       2107     2107              
============================================
+ Hits           6378     6380       +2     
+ Misses          392      387       -5     
- Partials        891      894       +3     
Flag Coverage Δ
unittests 83.27% <80.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../ruleset/rules/chapter6/classes/DataClassesRule.kt 85.07% <80.00%> (+2.98%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 632ac74...90db394. Read the comment docs.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 22, 2022

JUnit Tests (macOS, EnricoMi/publish-unit-test-result-action@v1)

1 317 tests   1 301 ✔️  2m 37s ⏱️
   160 suites       16 💤
   160 files           0

Results for commit 90db394.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 22, 2022

JUnit Tests (Windows, EnricoMi/publish-unit-test-result-action@v1)

1 331 tests   1 316 ✔️  2m 28s ⏱️
   161 suites       15 💤
   161 files           0

Results for commit 90db394.

♻️ This comment has been updated with latest results.

@orchestr7 orchestr7 force-pushed the bugfix/data-class-rules branch from 4800ee4 to ef977b9 Compare July 22, 2022 13:46
### What's done:
- Removed annotation, value, sealed, inline, inner classes from the scope
- Added tests
@orchestr7 orchestr7 force-pushed the bugfix/data-class-rules branch from 8f7af8c to 20b3e2c Compare July 23, 2022 20:05
### What's done:
- Removed annotation, value, sealed, inline, inner classes from the scope
- Added tests
return true
}

/** we do not exclude inner classes and enums here as if they have no
Copy link
Copy Markdown
Member

@petertrr petertrr Jul 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we filter out inner classes and enums elsewhere:

return list.getChildren(null)
.none { it.elementType in badModifiers } &&

private val badModifiers = listOf(OPEN_KEYWORD, ABSTRACT_KEYWORD, INNER_KEYWORD, SEALED_KEYWORD, ENUM_KEYWORD)

Copy link
Copy Markdown
Member Author

@orchestr7 orchestr7 Jul 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kek

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also I have no idea, why "open" is prohibited

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Copy Markdown
Member Author

@orchestr7 orchestr7 Jul 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but what is the idea? You have open class only with data and properties?
Why not abstract class in this case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are no abstract fields, than diktat will suggest to change abstract to open ¯\(ツ)

@orchestr7 orchestr7 force-pushed the bugfix/data-class-rules branch from 5205bad to 74039e2 Compare July 25, 2022 11:13
@orchestr7 orchestr7 merged commit 40a51a9 into master Jul 25, 2022
@orchestr7 orchestr7 deleted the bugfix/data-class-rules branch July 25, 2022 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

USE_DATA_CLASS: False positive for Annotations

6 participants