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

MatchingDeclarationName rule to match single declaration to file name #664

Closed
vanniktech opened this issue Jan 7, 2018 · 3 comments · Fixed by #674
Closed

MatchingDeclarationName rule to match single declaration to file name #664

vanniktech opened this issue Jan 7, 2018 · 3 comments · Fixed by #674
Assignees
Milestone

Comments

@vanniktech
Copy link
Contributor

If the file is named Foo.kt and there's only one declaration (object, class, enum or interface) this file name should match the declaration name.

Positive case:

Something.kt

object Something

Negative case:

Something.kt

object Somethin

Also I'd expect this check to work when there are top level variables declared:

Something.kt

const val MEANING_OF_LIFE = 42

object Something

What do you think?

@egor-n
Copy link
Contributor

egor-n commented Jan 8, 2018

The rule would mark this file, for example:
https://github.com/arturbosch/detekt/blob/994c732c5f45ebdbb50a917b272f87a9c0f5916f/detekt-rules/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexConditionSpek.kt#L12

@arturbosch
Copy link
Member

I want this rule too :D. Selfassigned.

@lock
Copy link

lock bot commented Jun 20, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants