Skip to content

Fix incomplete requireRootInDeclaration check in InvalidPackageDeclaration - #6045

Merged
cortinico merged 1 commit into
detekt:mainfrom
cketti:fix_InvalidPackageDeclaration
Apr 29, 2023
Merged

Fix incomplete requireRootInDeclaration check in InvalidPackageDeclaration#6045
cortinico merged 1 commit into
detekt:mainfrom
cketti:fix_InvalidPackageDeclaration

Conversation

@cketti

@cketti cketti commented Apr 26, 2023

Copy link
Copy Markdown
Contributor

The old code used String.startsWith() to check if the package declaration is the root package or a subpackage of it. This check erroneously allows "sibling packages" that start with the root package name, e.g. "com.example_extra" when the root package name is "com.example".

This PR adds a test for that case and fixes the check to work as intended.

@codecov

codecov Bot commented Apr 26, 2023

Copy link
Copy Markdown

Codecov Report

Merging #6045 (a595db9) into main (42a48d5) will decrease coverage by 0.01%.
The diff coverage is 82.35%.

@@             Coverage Diff              @@
##               main    #6045      +/-   ##
============================================
- Coverage     84.84%   84.83%   -0.01%     
- Complexity     3944     3946       +2     
============================================
  Files           561      561              
  Lines         13251    13256       +5     
  Branches       2313     2314       +1     
============================================
+ Hits          11243    11246       +3     
- Misses          868      869       +1     
- Partials       1140     1141       +1     
Impacted Files Coverage Δ
...h/detekt/rules/naming/InvalidPackageDeclaration.kt 91.89% <82.35%> (-4.99%) ⬇️

@cortinico cortinico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice catch 👍 Thanks for the fix @cketti

@cortinico
cortinico merged commit 704ca20 into detekt:main Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants