Skip to content

Fix incomplete requireRootInDeclaration check in InvalidPackageDeclaration #6045

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 1 commit into from
Apr 29, 2023

Conversation

cketti
Copy link
Contributor

@cketti cketti commented Apr 26, 2023

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
Copy link

codecov bot commented Apr 26, 2023

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%) ⬇️

Copy link
Member

@cortinico cortinico left a comment

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