Skip to content

Commit

Permalink
Cleanup codebase (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienvermeille authored Aug 20, 2024
1 parent 6aefeb8 commit 41ab4d5
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<sonar.projectKey>${project.sonar.root.projectKey}</sonar.projectKey>
<sonar.sources>src/main/java</sonar.sources>
<sonar.tests>src/test/java</sonar.tests>
<sonar.links.homepage>https://cookiecode.dev/oss_projects/StyleSniffer</sonar.links.homepage>
<sonar.links.homepage>https://stylesniffer.cookiecode.dev/</sonar.links.homepage>
<sonar.links.scm>https://github.com/sebastienvermeille/StyleSniffer</sonar.links.scm>

<!-- dependencies versions -->
Expand Down
2 changes: 2 additions & 0 deletions stylesniffer-annotation-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
<maven.compiler.target>${java.sdk.version}</maven.compiler.target>
<project.build.sourceEncoding>${source.encoding}</project.build.sourceEncoding>
<stylesniffer.root>${basedir}/..</stylesniffer.root>
<!-- sonar analysis -->
<sonar.projectKey>${project.sonar.root.projectKey}-${project.groupId}-${project.artifactId}</sonar.projectKey>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ public class RegisterCaseStyleAnnotationProcessor extends AbstractProcessor {
private static final String TEMPLATE_VARIABLE_GENERATED_AT = "generatedAt";
private static final String TEMPLATE_FILE_NAME = "case_style_injector";
private static final String POINT = ".";
private final Class<? extends Annotation> ANNOTATION_CLASS = RegisterCaseStyle.class;
private final Class<?> IMPLEMENTED_INTERFACE_CLASS = CaseStyle.class;
private static final Class<? extends Annotation> ANNOTATION_CLASS = RegisterCaseStyle.class;
private static final Class<?> IMPLEMENTED_INTERFACE_CLASS = CaseStyle.class;

@Override
public boolean process(
final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) {
final var annotatedElements = roundEnv.getElementsAnnotatedWith(this.ANNOTATION_CLASS);
final var annotatedElements = roundEnv.getElementsAnnotatedWith(ANNOTATION_CLASS);

if (!annotatedElements.isEmpty()) {
this.generateCaseStyleInjector(annotatedElements);
Expand Down Expand Up @@ -127,7 +127,7 @@ private Context prepareTemplateContext(final Set<? extends Element> elements) {
Generated.class.getCanonicalName(),
List.class.getCanonicalName(),
ArrayList.class.getCanonicalName(),
this.IMPLEMENTED_INTERFACE_CLASS.getCanonicalName());
IMPLEMENTED_INTERFACE_CLASS.getCanonicalName());
context.setVariable(TEMPLATE_VARIABLE_IMPORTS, imports.stream().sorted().collect(toList()));
context.setVariable(TEMPLATE_VARIABLE_CLASS_NAME, GENERATED_CLASS_NAME);

Expand Down
4 changes: 3 additions & 1 deletion stylesniffer-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
<maven.compiler.target>${java.sdk.version}</maven.compiler.target>
<project.build.sourceEncoding>${source.encoding}</project.build.sourceEncoding>
<stylesniffer.root>${basedir}/..</stylesniffer.root>
<!-- sonar analysis -->
<sonar.projectKey>${project.sonar.root.projectKey}-${project.groupId}-${project.artifactId}</sonar.projectKey>
</properties>

<dependencies>
Expand All @@ -51,4 +53,4 @@
</dependency>
</dependencies>

</project>
</project>
2 changes: 2 additions & 0 deletions stylesniffer-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
<maven.compiler.target>${java.sdk.version}</maven.compiler.target>
<project.build.sourceEncoding>${source.encoding}</project.build.sourceEncoding>
<stylesniffer.root>${basedir}/..</stylesniffer.root>
<!-- sonar analysis -->
<sonar.projectKey>${project.sonar.root.projectKey}-${project.groupId}-${project.artifactId}</sonar.projectKey>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ public Set<String> getVariantNames() {
* @param name the name to check
* @return {@code true} if the name is in snake_case, {@code false} otherwise
*/
private boolean isSnakeCase(
@NonNull
final String
name) { // TODO: consider creating an annotation @NonEmpty to indicate its handled
// upfront
private boolean isSnakeCase(@NonNull final String name) {
// Check if the name is all lowercase and contains underscores
boolean hasUnderscore = false;
for (int i = 0; i < name.length(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
*
* @author Sebastien Vermeille
*/
@SuppressWarnings(
"java:S2187") // sonar is not able to detect that BaseCaseStyleTest interface generates test
class KebabCaseStyleTest implements BaseCaseStyleTest<KebabCaseStyle> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
*
* @author Sebastien Vermeille
*/
@SuppressWarnings(
"java:S2187") // sonar is not able to detect that BaseCaseStyleTest interface generates test
class LowerCamelCaseStyleTest implements BaseCaseStyleTest<LowerCamelCaseStyle> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
*
* @author Sebastien Vermeille
*/
@SuppressWarnings(
"java:S2187") // sonar is not able to detect that BaseCaseStyleTest interface generates test
class PascalCaseStyleTest implements BaseCaseStyleTest<PascalCaseStyle> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
*
* @author Sebastien Vermeille
*/
@SuppressWarnings(
"java:S2187") // sonar is not able to detect that BaseCaseStyleTest interface generates test
class ScreamingSnakeCaseStyleTest implements BaseCaseStyleTest<ScreamingSnakeCaseStyle> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
*
* @author Sebastien Vermeille
*/
@SuppressWarnings(
"java:S2187") // sonar is not able to detect that BaseCaseStyleTest interface generates test
class SnakeCaseStyleTest implements BaseCaseStyleTest<SnakeCaseStyle> {

@Override
Expand Down
4 changes: 3 additions & 1 deletion stylesniffer-testkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
<maven.compiler.target>${java.sdk.version}</maven.compiler.target>
<project.build.sourceEncoding>${source.encoding}</project.build.sourceEncoding>
<stylesniffer.root>${basedir}/..</stylesniffer.root>
<!-- sonar analysis -->
<sonar.projectKey>${project.sonar.root.projectKey}-${project.groupId}-${project.artifactId}</sonar.projectKey>
</properties>

<dependencies>
Expand All @@ -63,4 +65,4 @@
</dependency>
</dependencies>

</project>
</project>

0 comments on commit 41ab4d5

Please sign in to comment.