Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule 6.4.1: Avoid using utility classes/objects #508

Merged
merged 18 commits into from
Dec 6, 2020
Merged

Conversation

kentr0w
Copy link
Collaborator

@kentr0w kentr0w commented Nov 10, 2020

Actions checklist

### What's done:
    Made a rule
@kentr0w kentr0w added the enhancement New feature or request label Nov 10, 2020
@codecov
Copy link

codecov bot commented Nov 10, 2020

Codecov Report

Merging #508 (e2f9f58) into master (6d31422) will decrease coverage by 0.03%.
The diff coverage is 73.91%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #508      +/-   ##
============================================
- Coverage     81.25%   81.21%   -0.04%     
- Complexity     1723     1738      +15     
============================================
  Files            87       88       +1     
  Lines          4551     4574      +23     
  Branches       1361     1371      +10     
============================================
+ Hits           3698     3715      +17     
  Misses          308      308              
- Partials        545      551       +6     
Flag Coverage Δ Complexity Δ
unittests 81.21% <73.91%> (-0.04%) 0.00 <15.00> (ø)

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

Impacted Files Coverage Δ Complexity Δ
...at-rules/src/main/kotlin/generated/WarningNames.kt 0.00% <ø> (ø) 0.00 <0.00> (ø)
...org/cqfn/diktat/ruleset/rules/AvoidUtilityClass.kt 71.42% <71.42%> (ø) 15.00 <15.00> (?)
...tlin/org/cqfn/diktat/ruleset/constants/Warnings.kt 97.61% <100.00%> (+0.01%) 11.00 <0.00> (ø)
...cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt 97.67% <100.00%> (+0.02%) 9.00 <0.00> (ø)

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 6d31422...e2f9f58. Read the comment docs.

### What's done:
   Fixed after review
### What's done:
   Fixed after review
# Conflicts:
#	diktat-analysis.yml
#	diktat-rules/src/main/kotlin/generated/WarningNames.kt
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
#	diktat-rules/src/main/resources/diktat-analysis-huawei.yml
#	diktat-rules/src/main/resources/diktat-analysis.yml
#	info/available-rules.md
### What's done:
   added suppress
Copy link
Member

@petertrr petertrr left a comment

Choose a reason for hiding this comment

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

https://github.com/cqfn/diKTat/pull/508/checks?check_run_id=1395759188

Caused by: kotlin.KotlinNullPointerException
    at org.cqfn.diktat.ruleset.rules.AvoidUtilityClass.checkClass (AvoidUtilityClass.kt:58)
    at org.cqfn.diktat.ruleset.rules.AvoidUtilityClass.visit (AvoidUtilityClass.kt:40)

### What's done:
   Fixed bug
# Conflicts:
#	diktat-analysis.yml
#	diktat-rules/src/main/kotlin/generated/WarningNames.kt
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
#	diktat-rules/src/main/resources/diktat-analysis-huawei.yml
#	diktat-rules/src/main/resources/diktat-analysis.yml
#	info/available-rules.md
### What's done:
    Fixed bug after review
# Conflicts:
#	diktat-analysis.yml
#	diktat-rules/src/main/kotlin/generated/WarningNames.kt
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
#	diktat-rules/src/main/resources/diktat-analysis-huawei.yml
#	diktat-rules/src/main/resources/diktat-analysis.yml
Copy link
Member

@petertrr petertrr left a comment

Choose a reason for hiding this comment

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

I've just realized that we should take into account tests: in tests there are usually classes with only methods, but they can't be converted. So, you should also check if none of the functions are from tests (we have some sort of method for this, checking file path and annotations).

### What's done:
    Added handle for tests dirs
### What's done:
    Added more tests
@petertrr petertrr changed the title Avoid using utility classes/objects Rule 6.4.1: Avoid using utility classes/objects Dec 3, 2020
Copy link
Member

@petertrr petertrr left a comment

Choose a reason for hiding this comment

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

LGTM, but let's merge it after #556

# Conflicts:
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt
### What's done:
   Fixed according to out code-style
### What's done:
   Fixed according to out code-style
### What's done:
   Fixed according to out code-style
### What's done:
   Fixed according to out code-style
### What's done:
   Fixed according to out code-style
### What's done:
   Fixed according to out code-style
Copy link
Member

@petertrr petertrr left a comment

Choose a reason for hiding this comment

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

LGTM

@kentr0w kentr0w merged commit 80cad9d into master Dec 6, 2020
@kentr0w kentr0w deleted the feature/rule-6.4.1 branch December 6, 2020 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule 6.4.1: Avoid using utility classes/objects, use extensions instead
2 participants