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

Fixing an NPE related to an Identifier Name #1111

Merged
merged 9 commits into from
Nov 9, 2021

Conversation

orchestr7
Copy link
Member

Which rule and warnings did you add?

This pull request closes

Actions checklist

  • Implemented Rule, added Warnings
  • Added tests on checks
  • Added tests on fixers
  • Updated diktat-analysis.yml
  • Updated available-rules.md

Fixme

### What's done:
- typos in warnings
### What's done:
- we expected that variables can only be declared in Classes (forgot about objects)
@@ -216,7 +194,7 @@ class IdentifierNaming(configRules: List<RulesConfig>) : DiktatRule(
}) {
// For class members also check `@property` KDoc tag.
// If we are here, then `variableName` is definitely a node from a class.
Copy link
Member

Choose a reason for hiding this comment

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

Then this comment is false?

Copy link
Member Author

Choose a reason for hiding this comment

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

node from a class OR an object...

Copy link
Member Author

Choose a reason for hiding this comment

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

also I made it NULL-safe. No more chances for an NPE here

@@ -216,7 +194,7 @@ class IdentifierNaming(configRules: List<RulesConfig>) : DiktatRule(
}) {
// For class members also check `@property` KDoc tag.
// If we are here, then `variableName` is definitely a node from a class.
variableName.parent(CLASS)!!.findChildByType(KDOC)?.kDocTags()
variableName.parent(CLASS)?:variableName.parent(OBJECT_DECLARATION)?.findChildByType(KDOC)?.kDocTags()
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
variableName.parent(CLASS)?:variableName.parent(OBJECT_DECLARATION)?.findChildByType(KDOC)?.kDocTags()
(variableName.parent(CLASS)?:variableName.parent(OBJECT_DECLARATION))?.findChildByType(KDOC)?.kDocTags()

?

Copy link
Member Author

Choose a reason for hiding this comment

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

elvis operator has the biggest priority, I guess...

Copy link
Member Author

@orchestr7 orchestr7 Nov 9, 2021

Choose a reason for hiding this comment

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

oh shit, fixed

orchestr7 and others added 5 commits November 9, 2021 17:05
…/Warnings.kt

Co-authored-by: Peter Trifanov <peter.trifanov@mail.ru>
### What's done:
- review notes
### What's done:
- review notes
@orchestr7 orchestr7 linked an issue Nov 9, 2021 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Nov 9, 2021

Codecov Report

Merging #1111 (554fb3a) into master (fd604b3) will not change coverage.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1111   +/-   ##
=========================================
  Coverage     83.43%   83.43%           
  Complexity     2462     2462           
=========================================
  Files           102      102           
  Lines          6146     6146           
  Branches       1840     1840           
=========================================
  Hits           5128     5128           
  Misses          274      274           
  Partials        744      744           
Flag Coverage Δ
unittests 83.43% <66.66%> (ø)

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

Impacted Files Coverage Δ
.../diktat/ruleset/rules/chapter1/IdentifierNaming.kt 82.02% <0.00%> (ø)
...tlin/org/cqfn/diktat/ruleset/constants/Warnings.kt 98.64% <100.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 fd604b3...554fb3a. Read the comment docs.

@orchestr7 orchestr7 enabled auto-merge (squash) November 9, 2021 14:44
@orchestr7 orchestr7 merged commit b188eab into master Nov 9, 2021
@orchestr7 orchestr7 deleted the bugfix/NPE-identifier-name branch November 9, 2021 14:57
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.

IDENTIFIER_NAME rule causes NPE
2 participants