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

Add style check and also fix style violations #3

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
plugins {
id 'java'
id 'maven-publish'

// spotless enforces style
id "com.diffplug.gradle.spotless" version "3.23.0"
}

repositories {
Expand Down Expand Up @@ -36,3 +39,12 @@ publishing {
}
}
}

// run google java format to enforce style
spotless {
// uncomment this line to temporarily disable spotless (i.e. when debugging)
// enforceCheck = false
java {
googleJavaFormat()
Copy link
Member

Choose a reason for hiding this comment

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

google-java-format produces bad formatting for type annotations.
Therefore, I don't think its use should be encouraged, in projects related to type annotations, until google/google-java-format#5 is fixed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you have a suggestion for a style checker that does not have bad formatting for type annotations? I'm not aware of one.

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/plume-lib/run-google-java-format
It's not as convenient to use (ugly Gradle integration), but it formats correctly.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import org.checkerframework.framework.qual.TargetLocations;
import org.checkerframework.framework.qual.TypeUseLocation;

/**
* The bottom type for the TemplateFora Checker's type system.
*/
/** The bottom type for the TemplateFora Checker's type system. */
@SubtypeOf({TemplateforaUnknown.class})
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import org.checkerframework.framework.qual.DefaultQualifierInHierarchy;
import org.checkerframework.framework.qual.SubtypeOf;

/**
* The top type for the TemplateFora Checker's type system.
*/
/** The top type for the TemplateFora Checker's type system. */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@DefaultQualifierInHierarchy
Expand Down
26 changes: 13 additions & 13 deletions src/test/java/tests/TemplateforaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
* https://github.com/typetools/checker-framework/blob/master/checker/tests/README .
*/
public class TemplateforaTest extends CheckerFrameworkPerDirectoryTest {
public TemplateforaTest(List<File> testFiles) {
super(
testFiles,
TemplateforaChecker.class,
"templatefora",
"-Anomsgtext",
"-Astubs=stubs/",
"-nowarn");
}
public TemplateforaTest(List<File> testFiles) {
Copy link
Member

Choose a reason for hiding this comment

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

The Checker Framework uses the -a command-line argument to google-java-format, for 4-space indentation.
I dislike that, but we might want to keep this project consistent with the other Checker Framework repositories.

super(
testFiles,
TemplateforaChecker.class,
"templatefora",
"-Anomsgtext",
"-Astubs=stubs/",
"-nowarn");
}

@Parameters
public static String[] getTestDirs() {
return new String[] {"templatefora"};
}
@Parameters
public static String[] getTestDirs() {
return new String[] {"templatefora"};
}
}