Skip to content

EndOfSentenceFormat - Fix #3893 by only calling super.visit once #3904

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

Merged
merged 2 commits into from
Jul 22, 2021
Merged

EndOfSentenceFormat - Fix #3893 by only calling super.visit once #3904

merged 2 commits into from
Jul 22, 2021

Conversation

schalkms
Copy link
Member

In #3660 the EndOfSentenceFormat rule got refactored.
The rule is called by the MultiRule 'KDocStyle'.
Both the called and calling visitor function execute a super.visit().
This can cause problems.
Hence, super.visit only called once with the changes made.

Suspicion:
Multiple KtDeclaration super.visit calls cause the crash in #3893.

In #3660 the EndOfSentenceFormat rule got refactored.
The rule is called by the MultiRule 'KDocStyle'.
Both the called and calling visitor function execute a super.visit().
This can cause problems.
Hence, super.visit only called once with the changes made.

Suspicion:
Multiple KtDeclaration super.visit calls cause the crash in #3893.
@codecov
Copy link

codecov bot commented Jun 25, 2021

Codecov Report

Merging #3904 (5262398) into main (66f20e7) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #3904      +/-   ##
============================================
+ Coverage     83.55%   83.58%   +0.03%     
- Complexity     3118     3122       +4     
============================================
  Files           456      456              
  Lines          8973     9012      +39     
  Branches       1746     1756      +10     
============================================
+ Hits           7497     7533      +36     
  Misses          564      564              
- Partials        912      915       +3     
Impacted Files Coverage Δ
...h/detekt/rules/documentation/DeprecatedBlockTag.kt 93.33% <ø> (-0.42%) ⬇️
.../detekt/rules/documentation/EndOfSentenceFormat.kt 95.23% <100.00%> (-0.22%) ⬇️
...arturbosch/detekt/rules/documentation/KDocStyle.kt 100.00% <100.00%> (ø)
...ls/src/main/kotlin/io/github/detekt/psi/KtFiles.kt 73.52% <0.00%> (-4.25%) ⬇️
...ekt/generator/printer/rulesetpage/ConfigPrinter.kt 92.10% <0.00%> (-0.76%) ⬇️
...bosch/detekt/generator/collection/Configuration.kt 100.00% <0.00%> (ø)
.../io/gitlab/arturbosch/detekt/generator/out/Yaml.kt 70.27% <0.00%> (+1.30%) ⬆️
...rturbosch/detekt/rules/style/UnusedPrivateClass.kt 73.33% <0.00%> (+3.33%) ⬆️
...ules/style/optional/MandatoryBracesIfStatements.kt 86.66% <0.00%> (+20.00%) ⬆️
...io/gitlab/arturbosch/detekt/core/BindingContext.kt 30.43% <0.00%> (+24.87%) ⬆️

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 66f20e7...5262398. Read the comment docs.

@schalkms schalkms added this to the 1.18.0 milestone Jun 25, 2021
Comment on lines +18 to +19
deprecatedBlockTag.visitDeclaration(dcl)
endOfSentenceFormat.visitDeclaration(dcl)
Copy link
Member

Choose a reason for hiding this comment

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

Does deprecatedBlockTag and endOfSentenceFormat each invokes super.visitDeclaration(dcl), thus in total calling twice?

Copy link
Member Author

Choose a reason for hiding this comment

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

Each rule calls its own super visit method. Before that, each rule called its own super visit method as well as the calling KDocStyle multi-rule.

Copy link
Member

Choose a reason for hiding this comment

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

I assume that before this PR, KDocStyle.visitDeclaration() is called but DeprecatedBlockTag.visitDeclaration is not invoked at runtime.

@cortinico
Copy link
Member

Are we ok merging this?

@chao2zhang chao2zhang merged commit 15980dc into detekt:main Jul 22, 2021
@cortinico cortinico changed the title Fix #3893 by only calling super.visit once EndOfSentenceFormat - Fix #3893 by only calling super.visit once Aug 5, 2021
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.

5 participants