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

PackageDeclaration: new property matchDirectoryStructure to match the package name to directory name of source file #3437

Closed
pepri opened this Issue Sep 11, 2016 · 5 comments

Comments

Projects
None yet
4 participants
@pepri

pepri commented Sep 11, 2016

The PackageDeclaration check should allow you to check whether the package name matches the directory name for the source file as stated in the documentation.

Maven compiles classes with non-matching package name just fine and I would like to prevent having such classes. After searching for this feature, I found out it was removed (#209). I think this change should be reverted, since the Java language specification doesn't force files to be in a certain directory.

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Nov 10, 2016

Member

we could restore removed option , but now it should be heavily documented.

Member

romani commented Nov 10, 2016

we could restore removed option , but now it should be heavily documented.

@rnveach rnveach added the easy label Mar 2, 2017

@kukreja-vikramaditya

This comment has been minimized.

Show comment
Hide comment
@kukreja-vikramaditya

kukreja-vikramaditya Mar 4, 2017

Contributor

I'm on it

Contributor

kukreja-vikramaditya commented Mar 4, 2017

I'm on it

@kukreja-vikramaditya

This comment has been minimized.

Show comment
Hide comment
@kukreja-vikramaditya

kukreja-vikramaditya Mar 4, 2017

Contributor

@romani
As per checkstyle's documentation, it is mentioned that PackageDeclaration can optionally check for package name and directory name mismatch. So I would need to create a new MSG_KEY like (mismatch.package.dir)? or edit the old one?

Contributor

kukreja-vikramaditya commented Mar 4, 2017

@romani
As per checkstyle's documentation, it is mentioned that PackageDeclaration can optionally check for package name and directory name mismatch. So I would need to create a new MSG_KEY like (mismatch.package.dir)? or edit the old one?

@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach Mar 4, 2017

Member

@kukreja-vikramaditya
Violation messages should be clear on guiding user to direct issue. Saying "Problem can be A or B" will be misguided and will require user to hunt down which one it is himself.
I don't see how original message can be updated and avoid that problem.
I think it is best to create a new message.

In addition to the logic change, we should have some example of new option in our xdoc. We should enable this option by default in our own configuration.

Member

rnveach commented Mar 4, 2017

@kukreja-vikramaditya
Violation messages should be clear on guiding user to direct issue. Saying "Problem can be A or B" will be misguided and will require user to hunt down which one it is himself.
I don't see how original message can be updated and avoid that problem.
I think it is best to create a new message.

In addition to the logic change, we should have some example of new option in our xdoc. We should enable this option by default in our own configuration.

kukreja-vikramaditya added a commit to kukreja-vikramaditya/checkstyle that referenced this issue Mar 5, 2017

kukreja-vikramaditya added a commit to kukreja-vikramaditya/checkstyle that referenced this issue Mar 5, 2017

kukreja-vikramaditya added a commit to kukreja-vikramaditya/checkstyle that referenced this issue Mar 7, 2017

kukreja-vikramaditya added a commit to kukreja-vikramaditya/checkstyle that referenced this issue Mar 9, 2017

kukreja-vikramaditya added a commit to kukreja-vikramaditya/checkstyle that referenced this issue Mar 10, 2017

kukreja-vikramaditya added a commit to kukreja-vikramaditya/checkstyle that referenced this issue Mar 10, 2017

kukreja-vikramaditya added a commit to kukreja-vikramaditya/checkstyle that referenced this issue Mar 11, 2017

kukreja-vikramaditya added a commit to kukreja-vikramaditya/checkstyle that referenced this issue Mar 15, 2017

rnveach added a commit that referenced this issue Mar 16, 2017

@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach Mar 16, 2017

Member

Fix is merged

Member

rnveach commented Mar 16, 2017

Fix is merged

@rnveach rnveach closed this Mar 16, 2017

@rnveach rnveach added this to the 7.7 milestone Mar 16, 2017

sagar-shah94 pushed a commit to sagar-shah94/checkstyle that referenced this issue Mar 18, 2017

GitToasterhub added a commit to GitToasterhub/checkstyle that referenced this issue Mar 18, 2017

SergeyDzyuba added a commit to SergeyDzyuba/checkstyle that referenced this issue Mar 22, 2017

@romani romani changed the title from PackageDeclaration does not check whether the package name matches the directory name for the source file to PackageDeclaration: new property matchDirectoryStructure to match the package name to directory name of source file Mar 28, 2017

@romani romani added medium and removed easy labels Apr 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment