61 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
40643855c4 do not let Jackson set instance vars that never come from index
Tell the Jackson JSON parser to ignore App/Apk fields that should never
come from the index, but instead are set locally to keep track of the
current state of things on the device.

There are two forms of tests to enforce that the proper things get
ignored.  It is not possible to do this with decorators alone, so I
chose to use @JsonIgnore and leave the variables we want filled in
undecorated.  Also, all of the instance variables in Apk/App/Repo
should come directly from the index metadata so that they are pure
data classes.  Currently some state info is stored in them, those are
decorated with @JsonIgnore.

The tests then include lists of accepted and ignored properties, and
anything that is not in those lists will cause the tests to fail.  So
if someone is adding a new instance variable, they will get a fail
until the tests are updated.  One set of tests actually writes blank
instances out as JSON since that's the easiest test to write, and
Jackson treats @JsonIgnore the same in both directions.  Then there is
another test that reads a JSON file with added, unsupported values to
make sure that they are properly ignored.
2017-03-31 09:09:31 +11:00
Peter Serwylo
4f7116fcfb Add checkstyle rule to catch usage of member variables prefixed with 'm' 2016-12-05 22:56:26 +11:00
Daniel Martí
8af44b1af5 checkstyle: bump to 7.0
Remove LITERAL_DO from the config in RightCurly as we want this:

        do {
            foo;
        } while (bar);

Not this:

        do {
            foo;
        }
        while (bar);

This went unnoticed as LITERAL_DO was broken in RightCurly in earlier
Checkstyle versions.
2016-07-04 11:31:41 +01:00
Peter Serwylo
53e74dcdbd Appease checkstyle for test code.
Like PMD, we also had to add a concession to allow static imports.
This time, it was achieved by moving the assertions to a more generally
named `Assert` class, and then allowing static imports from that.
2016-06-09 10:44:40 +10:00
Peter Serwylo
4e73d1e5e6 Finish porting tests to Robolectric, and appease PMD.
To appease PMD, we now have a three rulesets in `config/pmd/*.xml`:

 * `rules.xml`: The bulk of the rules, used by both main and test code.
 * `rules-main.xml`: Rules specific to the andoid client code.
 * `rules-test.xml`: Rules specific to test code.

The rationale is because checkstyle by default checks for "too many static
imports", which is a fair call. However in JUnit4 code, it is common to
import many `assert*` static methods.
2016-06-09 10:44:40 +10:00
Daniel Martí
c432bf1ea0 PMD: Enable most empty code rules 2016-05-12 13:34:20 +01:00
Daniel Martí
65e2931fe8 PMD: Enable UnnecessaryWrapperObjectCreation 2016-05-12 13:34:20 +01:00
Hans-Christoph Steiner
7fbdfaaae7 enable PMD's java-basic ruleset
* CollapsibleIfStatements is pedantic
* that one NOPMD is for debug logging, it'll go away

closes #623 https://gitlab.com/fdroid/fdroidclient/issues/623
2016-05-12 09:36:08 +02:00
Daniel Martí
78af79cd4f checkstyle: enable OneTopLevelClass
The only remaining error was ClipboardCompat, which was unnecessarily
exposing three top-level classes. Make the two implementation classes be
nested, private and static.
2016-05-07 21:28:06 +01:00
Daniel Martí
023a6d01bd PMD: Enable some extra boolean/logic rules 2016-04-29 19:22:30 +01:00
Daniel Martí
ac8d3ff600 PMD: Enable and obey UnnecessaryParentheses
This works on statements, not expressions, so it's a lot easier and
saner to obey than UselessParentheses.
2016-04-29 19:22:04 +01:00
Daniel Martí
e5bc365b64 PMD: Enable a bunch of strictexception rules
We already obey them.
2016-04-28 17:17:17 +01:00
Daniel Martí
50b2e6f7a5 PMD: Enable and obey SingularField 2016-04-23 17:27:22 +01:00
Daniel Martí
68db3ae353 PMD: Enable and obey ImmutableField 2016-04-23 17:27:22 +01:00
Daniel Martí
c746a49b15 PMD: Enable some design.xml rules we already obey 2016-04-23 17:27:22 +01:00
Daniel Martí
f655f49aee PMD: Enable and obey UnnecessaryConstructor 2016-04-23 16:17:55 +01:00
Daniel Martí
857b0ea1c7 PMD: Enable and obey AddEmptyString 2016-04-23 16:14:05 +01:00
Daniel Martí
5d3d8786e2 PMD: Enable and obey PrematureDeclaration 2016-04-23 16:06:41 +01:00
Daniel Martí
32c67d05ec PMD: XML config file, enable most of unnecessary 2016-04-23 15:59:04 +01:00
Hans-Christoph Steiner
9656de0147 remove checkstyle ExplicitInitialization check
"Variable explicitly initialized to 'false' (default value for its type)"

I never remember what the default init value of booleans are, so this error
is quite annoying to me, and I can't see the harm of this behavior.
checkstyle says: "So in this case, x gets initialized to 0 twice, and bar
gets initialized to null twice. So there is a minor inefficiency."
2016-03-29 10:57:55 +02:00
Hans-Christoph Steiner
538830d5a3 ignore checkstyle AvoidStaticImport for test frameworks
For whatever reason, both JUnit and Google recommend using static method
imports when writing tests.
2016-03-29 10:57:55 +02:00
Daniel Martí
17c731ef1d checkstyle: obey ConstantName 2016-02-17 15:59:04 +00:00
Daniel Martí
a6b804e93a checkstyle: obey NeedBraces on multi-line stmts
We still allow them in single-line statements, like:

	if (foo) bar;
	for (int i : ints) bar;

Everything else should use braces to help readability and avoid silly
human mistakes that might result in bugs.

These changes were completely automated via a python script.
2016-02-17 12:04:36 +00:00
Daniel Martí
6ab5299e40 checkstyle: clean up modules we'll never use 2016-01-06 21:51:23 +01:00
Daniel Martí
3a8051898a checkstyle: be more strict with curly rules 2015-12-29 22:18:38 +01:00
Daniel Martí
c1d4248723 checkstyle: Check comment indentation too 2015-12-29 22:10:19 +01:00
Daniel Martí
9efe173380 checkstyle: Finally add proper indentation checks
Somewhat painful conversion, but should go much smoother from here
onward.
2015-12-29 22:00:23 +01:00
Daniel Martí
dd4420965d checkstyle: Add more rules that we already obey 2015-12-29 21:43:29 +01:00
Daniel Martí
7ed03bdcba checkstyle: EmptyLineSeparator is now fixed 2015-12-29 12:59:21 +01:00
Daniel Martí
0f27374452 checkstyle: forbid inner assignments 2015-12-29 12:55:29 +01:00
Daniel Martí
8405ba7d87 checkstyle: proper multiple empty line check
Hopefully checkstyle could catch all of these on its own one day. For
now, help it via a multiline regex.
2015-11-30 11:30:49 +01:00
Daniel Martí
1e79b6d1d5 checkstyle: add TODO regarding func wrapping 2015-11-30 11:04:12 +01:00
Daniel Martí
098241c981 checkstyle: don't allow multiple empty lines 2015-11-30 10:40:35 +01:00
Daniel Martí
04e730c6bb checkstyle: add AnnotationLocation 2015-11-30 10:38:49 +01:00
Daniel Martí
1e8bbbd1f9 checkstyle: Add curly checks 2015-10-09 11:40:50 +02:00
Daniel Martí
8396eba8d9 checkstyle: Always wrap commas 2015-10-09 11:27:24 +02:00
Daniel Martí
6b573db3f4 checkstyle: Add more checks we already obey 2015-10-09 11:06:59 +02:00
Daniel Martí
65f292708c checkstyle: Add AvoidStaticImport
Plus bonus build fix (whoops).
2015-10-09 11:04:39 +02:00
Daniel Martí
2249ad59da checkstyle: Add StaticVariableName 2015-10-09 11:02:19 +02:00
Daniel Martí
caa91186cc checkstyle: Add LocalFinalVariableName 2015-10-09 10:59:44 +02:00
Daniel Martí
6ee3dba3ea checkstyle: Add LocalVariableName 2015-10-09 10:56:50 +02:00
Daniel Martí
b5f62c03cb checkstyle: Add MemberName 2015-10-09 10:55:27 +02:00
Daniel Martí
48b7096523 checkstyle: Enable some naming checks we obey 2015-10-09 10:50:13 +02:00
Daniel Martí
bd68caa152 checkstyle: Add FallThrough
With bonus bugfix.
2015-10-08 23:33:29 +02:00
Daniel Martí
638daf83cf checkstyle: Add OneStatementPerLine
Also OneTopLevelClass, but we're not there yet
2015-10-08 22:29:32 +02:00
Daniel Martí
d97319efb7 checkstyle: Add DefaultComesLast 2015-10-08 22:25:38 +02:00
Daniel Martí
7bbcbf25a6 checkstyle: Add EmptyLineSeparator 2015-10-08 22:23:10 +02:00
Daniel Martí
f5352eaf28 checkstyle: Add ArrayTrailingComma 2015-10-08 22:15:51 +02:00
Daniel Martí
3f8875ab9c checkstyle: Add EqualsAvoidNull 2015-10-08 22:09:51 +02:00
Daniel Martí
174e37e4e0 checkstyle: Add ExplicitInitialization 2015-10-08 22:01:09 +02:00