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

Bugfix/long line in string template #1297

Merged
merged 63 commits into from
Jun 16, 2022
Merged

Conversation

Arrgentum
Copy link
Member

@Arrgentum Arrgentum commented May 24, 2022

Fix logic in LineLength rule

This pull request closes #1243

Actions checklist

  • Corrected logic fix and warn String Template
  • Added logic fix and warn long Dot Qualified Expression(. !!.) and Safe Access Expression(?.)
  • Added logic fix and warn Value Arguments List
  • Added logic fix and warn When Entry
  • Correct fun ASTNode.appendNewlineMergingWhiteSpace in AstNodeUtils.kt
  • Added and corrected fix and warn tests

Arrgentum added 7 commits May 16, 2022 16:36
 * Start logic to fix and warn String Template in Linelength rule
# Conflicts:
#	diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt
 * Start logic to fix and warn String Template in Linelength rule
 * Start logic to fix and warn String Template in Linelength rule
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule

 ### Issue (#1243)
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat

 ### Issue (#1243)
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions

 ### Issue (#1243)
@codecov
Copy link

codecov bot commented May 24, 2022

Codecov Report

Merging #1297 (f29777f) into master (aa093cc) will decrease coverage by 0.11%.
The diff coverage is 83.39%.

@@             Coverage Diff              @@
##             master    #1297      +/-   ##
============================================
- Coverage     83.67%   83.56%   -0.12%     
+ Complexity     2588     2572      -16     
============================================
  Files           106      106              
  Lines          7387     7507     +120     
  Branches       2048     2076      +28     
============================================
+ Hits           6181     6273      +92     
- Misses          354      357       +3     
- Partials        852      877      +25     
Flag Coverage Δ
unittests 83.56% <83.39%> (-0.12%) ⬇️

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

Impacted Files Coverage Δ
...g/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt 84.57% <83.39%> (-4.88%) ⬇️
...cqfn/diktat/ruleset/utils/PositionInTextLocator.kt 92.50% <0.00%> (+7.50%) ⬆️

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 aa093cc...f29777f. Read the comment docs.

Arrgentum added 12 commits May 24, 2022 18:27
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * correct code with running detect

 ### Issue (#1243)
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * correct code with running detect

 ### Issue (#1243)
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * correct code with running detect

 ### Issue (#1243)
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * correct code with running detect

 ### Issue (#1243)
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * correct code with running detect

 ### Issue (#1243)
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * correct code with running detect

 ### Issue (#1243)
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * correct code with running detect

 ### Issue (#1243)
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * correct code with running detect

 ### Issue (#1243)
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * correct code with running detect

 ### Issue (#1243)
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * correct code with running detect

 ### Issue (#1243)
 * corrected logic fix and warn String Template in Linelength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * correct code with running detect

 ### Issue (#1243)
 * corrected logic fix and warn String Template in LineLength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * correct code with running detect

 ### Issue (#1243)
### Whats added:
 * corrected logic fix and warn String Template in LineLength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * moved fix logic to class methods
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * corrected code

 ### Issue (#1243)
Arrgentum added 2 commits June 7, 2022 20:03
### Whats added:
 * corrected logic fix and warn String Template in LineLength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * moved fix logic to class methods
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * corrected code

 ### Issue (#1243)
### Whats added:
 * corrected logic fix and warn String Template in LineLength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * moved fix logic to class methods
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * corrected code

 ### Issue (#1243)
Arrgentum added 6 commits June 7, 2022 20:34
### Whats added:
 * corrected logic fix and warn String Template in LineLength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * moved fix logic to class methods
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * corrected code

 ### Issue (#1243)
### Whats added:
 * corrected logic fix and warn String Template in LineLength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * moved fix logic to class methods
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * corrected code

 ### Issue (#1243)
### Whats added:
 * corrected logic fix and warn String Template in LineLength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * moved fix logic to class methods
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * corrected code

 ### Issue (#1243)
### Whats added:
 * corrected logic fix and warn String Template in LineLength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * moved fix logic to class methods
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * corrected code

 ### Issue (#1243)
### Whats added:
 * corrected logic fix and warn String Template in LineLength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * moved fix logic to class methods
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * corrected code

 ### Issue (#1243)
### Whats added:
 * corrected logic fix and warn String Template in LineLength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * moved fix logic to class methods
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * corrected code

 ### Issue (#1243)
### Whats added:
 * corrected logic fix and warn String Template in LineLength rule
 * added logic fix and warn long Dot Qualified Expression and Safe Access Expression in LineLength rule
 * added logic fix and warn Value Arguments List in LineLength rule
 * added and corrected fix and warn tests in LineLength rule
 * moved fix logic to class methods
 * fix code with diktat:fix@diktat
 * added comments to classes and functions
 * corrected code

 ### Issue (#1243)
val parentIsFunctionLiteral = parent.treeParent.treeParent.elementType == FUNCTION_LITERAL
val parentIsFunOrProperty = parent.treeParent.elementType in listOf(FUN, PROPERTY)
return (parentIsBiExprOrParenthesized || parentIsFunctionLiteral || (parentIsFunOrProperty && offset >= configuration.lineLength))
private fun findParentNodeMatching(node: ASTNode, listType: List<IElementType>): ASTNode? {
Copy link
Member

Choose a reason for hiding this comment

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

suggestion to extend org.cqfn.diktat.ruleset.utils.AstNodeUtilsKt#findParentNodeWithSpecificType to support elementType as varags

return binList.map {
it to positionByOffset(it.getFirstChildWithType(OPERATION_REFERENCE)!!.startOffset).second
}
@Suppress("MAGIC_NUMBER", "MagicNumber")
Copy link
Member

Choose a reason for hiding this comment

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

@akuleshov7 @petertrr, as I got, there are two different rules from diktat and detect -- is it possible to support suppressing from detect on diktat level to avoid duplication?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we should probably tune detekt.yaml a little and turn off these overlapping rules.

@Arrgentum Arrgentum enabled auto-merge (squash) June 15, 2022 14:07
@Arrgentum Arrgentum disabled auto-merge June 15, 2022 14:08
@Arrgentum Arrgentum enabled auto-merge (squash) June 15, 2022 15:02
@Arrgentum Arrgentum disabled auto-merge June 15, 2022 15:36
@Arrgentum Arrgentum merged commit 48360cd into master Jun 16, 2022
@Arrgentum Arrgentum deleted the bugfix/LongLine_in_StringTemplate branch June 16, 2022 08:48
This was referenced Jun 21, 2022
@Arrgentum Arrgentum self-assigned this Jun 21, 2022
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.

Error in rule LONG_LINE in string template
4 participants