-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Issues#238 Rule About package name #246
Conversation
- package name should match directory name which kotlin file exists. - package name should not contians UpperCase characters and UnderScore. https://android.github.io/kotlin-guides/style.html#package-names
In this rule, We can use camel case package name. |
Thank you, @yokotaso! |
@yokotaso @shyiko This change does not check for UpperCase characters in package names; in fact, it now has a test to make sure that they are allowed: |
@thauk-copperleaf yes. UpperCase is allwoed. But UpperCase is now allowed this rule: |
@yokotaso The first link disallows them, then allows them in the same paragraph. Very confusing! The second link disallows them.
|
While I'm 100% with Android Style Guide on this (keep package names in lowercase), ktlint is not enforcing this rule for one simple reason: there are plenty of projects that use ktlint and have package names in camelCase. We cannot expect people to rename packages considering a breaking nature of the change. Hence - not enforced. |
@shyiko Many projects also have package names such as: big_example and introducing any rule regarding this stops these big sized projects from updating their ktlint version. Do you have any suggestions for these kind of projects? |
@sanogueralorenzo right now the only option is to use
While I always check a handful of public repos before adding new rules (there are no packages containing _ in Mozilla/Google/WordPress/... repos) I realize that some of the assumptions might hold true for everyone. If you can provide a list of projects that have _ in their package names - I'll consider removing the rule from ktlint. |
@sanogueralorenzo Isn't that possible for any rule ktlint may introduce? |
@thauk-copperleaf not really. Let's assume project foo (used by baz, qux, etc) has a package com.foo.bar_baz. You are the maintainer of foo. Imagine you decided to add ktlint. Differences in code style can be easily rectified (using |
What I mean is, ktlint could introduce a rule that is violated by a major software project, so is that a sufficient reason to not introduce the rule? |
For a rule to be added
Whether it's violated by "a major software project" does not matter. |
Did further research and package name with underscore is accepted but never recommended. While it is true that most repos don't follow this rule it still leaves some projects that might have it because for reason X decided to not follow this convention. 😅 Comparing it to the wildcard import (that could easily get fixed with the help of the IDE and format) this one is a bit trickier as seen in the example above by @shyiko Current solutions that I can think of:
Thoughts? |
Sorry for my poor implementation rule. |
There are rules about package name: - https://kotlinlang.org/docs/reference/coding-conventions.html#naming-rules - https://android.github.io/kotlin-guides/style.html#package-names if we will check it, Backword compatibility is missing. So, This rule check structure of directory. See also: * https://kotlinlang.org/docs/reference/coding-conventions.html#directory-structure * pinterest#246 (comment)
@shyiko I'm sorry to trouble apologize... 😭 |
@yokotaso you have absolutely nothing to be sorry about. The rule works the way it was designed. Honestly, you did a good job. I'm still not sure we should disable it ( |
@yokotaso Not at all! Sorry if my message came across that way. I was just asking for suggestions to deal with a situation where a project is using _ extensively due to a previous convention. |
Hi, Thank you for review #228 #243
And I develop #238
And then, I noticed bellow coding style rules. This PR includes addtional rule.
https://android.github.io/kotlin-guides/style.html#package-names
Thanks!