Skip to content

Enforce that enum names must be singular, not plural. #520

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
Jun 7, 2018

Conversation

millems
Copy link
Contributor

@millems millems commented Jun 4, 2018

Reviewer notes: New checkstyle rule implemented in "PluralEnumNames.java". This does not apply to modeled objects.

@millems millems requested a review from shorea June 4, 2018 23:13
}

private boolean isPlural(String className) {
return DISALLOWED_ENDINGS.stream().anyMatch(className::endsWith) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

It's kind of confusing to name them allowed/disallowed since it depends more on the context in which they are used whether they are allowed or not. Perhaps just PLURAL_ENDINGS and NON_PLURAL_ENDINGS or something along those lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

}

private boolean isPluralDisallowed(DetailAST ast) {
return !isEnum(ast) && !hasPublicStaticField(ast);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this right? It seems backwards to me but perhaps my brain is at reduced capacity right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I changed it elsewhere and forgot to change it here. Good catch.

@@ -28,15 +28,15 @@

public final class DocumentationUtils {

public static final String DEFAULT_SETTER = "Sets the value of the %s property for this object.";
private static final String DEFAULT_SETTER = "Sets the value of the %s property for this object.";
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm this feels like cheating... ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, a little :)

@@ -24,7 +24,7 @@
import software.amazon.awssdk.utils.http.SdkHttpUtils;

@SdkProtectedApi
public final class PathMarshallers {
public abstract class PathMarshaller {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this still be an interface? Or does it have something to do with the private static classes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing can be private in an interface (before Java 9).

*/
public enum KnownJavaVersions {
public enum KnownJavaVersion {
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably needs to go. Can you add a review before release?

@@ -22,7 +22,7 @@
* Default configuration values.
*/
@ReviewBeforeRelease("These values")
public final class Defaults {
public final class Default {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rename to DefaultConfiguration or DefaultSetting

@millems millems force-pushed the millem/singular-enums branch 3 times, most recently from 842bc8f to b63ea14 Compare June 7, 2018 21:19
@millems millems force-pushed the millem/singular-enums branch from b63ea14 to cd06399 Compare June 7, 2018 21:23
@millems millems merged commit 4adbc31 into master Jun 7, 2018
@millems millems deleted the millem/singular-enums branch June 7, 2018 22:13
aws-sdk-java-automation added a commit that referenced this pull request Jun 3, 2019
…e6f1604b

Pull request: release <- staging/42a93eca-9b2f-49b8-a049-4ad6e6f1604b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants