-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #31: Add lint for fields-only classes.
This adds a lint to make sure that classes that only contain final fields have a protected or public constructor in the API so that external clients can mock these classes. It also checks that these classes are not final for test subclassing.
- Loading branch information
Showing
7 changed files
with
64 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
apilint/src/test/resources/apilint_test/test-fields-only-class-final.after.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package test { | ||
public final class FieldOnlyTest { | ||
ctor protected FieldOnlyTest(); | ||
field public final int testField0; | ||
field public final int testField1; | ||
field public final int testField2; | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
apilint/src/test/resources/apilint_test/test-fields-only-class-final.before.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package test { | ||
} |
7 changes: 7 additions & 0 deletions
7
apilint/src/test/resources/apilint_test/test-fields-only-class.after.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package test { | ||
public class TestFieldsOnly { | ||
field public final int testField0; | ||
field public final int testField1; | ||
field public final int testField2; | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
apilint/src/test/resources/apilint_test/test-fields-only-class.before.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package test { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters