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

Codestyle, chapter 6 #421

Merged
merged 5 commits into from
Oct 21, 2020
Merged

Codestyle, chapter 6 #421

merged 5 commits into from
Oct 21, 2020

Conversation

orchestr7
Copy link
Member

What's done:

  1. Added class related rules

### What's done:
1) Added class related rules
@@ -10,7 +10,8 @@
| [2 Comments](#c2) | [Kdoc](#c2.1), [File header](#c2.2), [Function header comments](#c2.3), [Code comments](#c2.4) |
| [3 General format](#c3) | [File-related rules](#c3.1), [Indentation](#c3.2), [Empty blocks](#c3.3), [Line width](#c3.4), [Line breaks (newlines)](#c3.5), [Blank lines](#c3.6), [Horiznotal alignment](#c3.7), [Enumerations](#c3.8), [Variable declaration](#c3.9), [When expression](#c3.10), [Annotations](#c3.11), [Comment layout](#c3.12), [Modifiers](#c3.13), [Strings](#c3.14)|
| [4 Variables and types](#c4) | [Variables](#c4.1), [Types](#c4.2), [Null safety and variable declarations](#4.3)|
| [5 Functions](#c5) | [Function design](#c5.1) [Function parameters](#c5.2)|
| [5 Functions](#c5) | [Function design](#c5.1), [Function parameters](#c5.2)|
| [6 Classes](#c6) | [Classes](#c6.1), [Interfaces](#c6.2), [Objects](#c6.3)|
Copy link
Member Author

@orchestr7 orchestr7 Oct 18, 2020

Choose a reason for hiding this comment

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

have no ideas by for now about 6.2. and 6.3, but I will think
already written too many rules ...

@codecov
Copy link

codecov bot commented Oct 18, 2020

Codecov Report

Merging #421 into master will increase coverage by 0.21%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #421      +/-   ##
============================================
+ Coverage     82.49%   82.71%   +0.21%     
- Complexity     1347     1359      +12     
============================================
  Files            65       66       +1     
  Lines          3314     3401      +87     
  Branches       1056     1078      +22     
============================================
+ Hits           2734     2813      +79     
+ Misses          179      172       -7     
- Partials        401      416      +15     
Flag Coverage Δ Complexity Δ
#unittests 82.71% <ø> (+0.21%) 1359.00 <ø> (+12.00)

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

Impacted Files Coverage Δ Complexity Δ
...kotlin/org/cqfn/diktat/ruleset/rules/FileNaming.kt 90.47% <ø> (ø) 8.00 <0.00> (ø)
...n/kotlin/org/cqfn/diktat/ruleset/utils/PsiUtils.kt 46.87% <0.00%> (ø) 0.00% <0.00%> (ø%)
...tlin/org/cqfn/diktat/ruleset/utils/ASTConstants.kt 100.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
...cqfn/diktat/ruleset/utils/PositionInTextLocator.kt 83.33% <0.00%> (ø) 0.00% <0.00%> (?%)
...tlin/org/cqfn/diktat/ruleset/utils/AstNodeUtils.kt 82.15% <0.00%> (+0.08%) 0.00% <0.00%> (ø%)
...fn/diktat/ruleset/rules/files/FileStructureRule.kt 75.47% <0.00%> (+15.47%) 32.00% <0.00%> (+12.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 4576e59...e78816e. Read the comment docs.

```

### <a name="r6.1.2"></a> Rule 6.1.2: Prefer data classes instead of classes without any functional logic
Some people say that data class - is a code smell, but in case you really need to use it and your is becoming more simple because of that -
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Some people say that data class - is a code smell, but in case you really need to use it and your is becoming more simple because of that -
Some people say that data class - is a code smell, but in case you really need to use it and your code is becoming more simple because of that -

I thought data classes are one of the killer-features of kotlin, do we really need to mention in our code style that it is considered a code smell?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's why I say "some people" say :))
https://refactoring.guru/smells/data-class

}
```

In this case the name of backing property (`_table`) should be the same to the name of real property (`table`), but should have underscore (`_`) prefix.
Copy link
Member

Choose a reason for hiding this comment

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

Will this clash with requirements of identifier naming chapter?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, hm, that is true - I will mention it

@orchestr7 orchestr7 merged commit 57df3f4 into master Oct 21, 2020
@petertrr petertrr deleted the feature/chapter6 branch October 22, 2020 17:27
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.

2 participants