Commit Graph

31 Commits

Author SHA1 Message Date
Alan Viverette
50fb0a915b Allow passing custom checks to checkstyle
Bug: 32998581
Change-Id: Icf349a8ff47ebc434958b872f5729b126e67bcbb
2016-12-05 12:44:23 -05:00
Aurimas Liutikas
fff72bd810 Merge "Removing pre-push.py git hook for checkstyle." 2016-11-30 22:02:31 +00:00
Aurimas Liutikas
1253b5accf Loosen up the checks for test class paths in Checkstyle.
This change allows us to skip javadoc checks for such test directories:
- cts/tests/tests/
- /test/src/

Test: none
Change-Id: I6a3bedaed816a3e764ca7e66ee364cd30e16c55b
2016-11-22 14:51:02 -08:00
Aurimas Liutikas
0f2de36ee9 Reland allowing MockitoAnnotations.* as static import.
It was originally added internally in ag/1085881, but then got
reverted via merge when android-styles.xml got split into multiple
files in r.android.com/305437

Bug: None
Test: None
Change-Id: I08bde16212c563a8d43995a97ffe47b2c43ed952
2016-11-18 17:12:12 -08:00
Aurimas Liutikas
44b6f1092b Removing pre-push.py git hook for checkstyle.
Checkstyle is now invoked using repo upload hooks and this script
is no longer needed.

Test: None
Change-Id: I2cdf38cc84c9f65efad76df1d58a5261b954fca8
2016-11-18 17:08:20 -08:00
Aurimas Liutikas
36824c93ee Split android-style.xml into modules for checkstyle.
This will allow teams to reuse parts of checkstyle without having
to worry about missing any checks when they change in the main configs.

Bug: None
Test: Tested locally and checkstyle still verifies the same rules using android-style.xml
Change-Id: I91ca11d3d7089db656bc640549bd7012284a8859
2016-11-18 15:55:15 -08:00
Aurimas Liutikas
2ae3a31c44 Skip all the ckecks for test data files.
Test: None
Change-Id: I492f1c7f97455fa08f135b375db7abb9d734c4b7
2016-11-10 13:36:31 -08:00
Aurimas Liutikas
e847694a3d Print the project name if available when running Checkstyle.
Add [project/foo/bar] to the beginning of each Checkstyle error line
if the REPO_PROJECT environmental variable is set (set by repo hooks).

Test: manually attempted to run checkstyle.
Change-Id: I8ccf76d9ce9306668109029267081924300cb6ce
2016-11-03 09:45:33 -07:00
Aurimas Liutikas
e9eaf62130 Correct the previous patch for test file subpaths in Checkstyle.
Instead of /tests/* allow /src/test/* subpath to be marked as test code.

Test: None
Change-Id: I6e9699a34de6d2bc167afa80539949be5a6a8907
2016-11-02 17:32:34 -07:00
Aurimas Liutikas
5a4c535344 Expand the allowed subpaths for test directories.
Include /test/* in addition to /tests/*.

Test: None
Change-Id: I3f09596cfe97c40bb3c30288de2e6696c4a5725b
2016-11-02 16:00:01 -07:00
Aurimas Liutikas
794494e88f Add tests/test-data/ to test file list for Checkstyle
This will skip javadoc checks for Java files in tests/test-data.

Bug: None
Test: None
Change-Id: I517f7d28d49e66c6c7029787e377fbbfe6df8154
2016-10-28 10:08:35 -07:00
Aurimas Liutikas
21b3a7463b Add file whitelisting capabilities to checkstyle.py
Certain projects might want to enable checkstyle gradually so
we need a way to whitelist which files should be checked.

Test: added test_FilterFiles
Change-Id: I501677ce824f882ccb5f2ad129af8f596d01c6e8
2016-10-11 13:52:46 -07:00
Aurimas Liutikas
b40478c7fa Disable Checkstyle checks on auto-generated files.
Add a check to ignore changes to automatically generated classes.

Bug: None
Test: Tried to run checkstyle locally on a file that containted the comment
      and checkstyle script showed no warnings even though that file had issues.
Change-Id: If9085948f1c224dbb53255b2ba1601511ef769dd
2016-09-20 16:46:12 -07:00
Aurimas Liutikas
fc518c714c Do not warn about uncommited files if sha is set explicitly.
Bug: 31603810
Test: Added test_GetModifiedFilesUncommittedExplicitCommit, all tests pass
Change-Id: I953f22df5be8030fc8a7145531026220c97a8dd8
2016-09-20 10:23:34 -07:00
Aurimas Liutikas
0b77686215 Allow missing method Javadocs for test classes in Checkstyle.
Bug: None
Test: Existing test_ShouldSkip will test this as it is using
      checkstyle.SKIPPED_RULES_FOR_TEST_FILES

Change-Id: I56c8c86a36f93b6b72a87fd97b75e5233fde9077
2016-09-20 10:19:48 -07:00
Maurice Lam
d513a1723f Add custom config XML support for checkstyle
Change-Id: If94dd073d7270d8fcdcf4f3041770712a193ce9e
2016-03-16 14:53:15 -07:00
Mitchell Wills
753fae1d8b Checkstyle: Allow star imports for certain classes
Bug: 27282855
Change-Id: Iab492c8b558e37af0dded33d99e309c4fd559b05
2016-02-21 12:11:32 -08:00
Aurimas Liutikas
e556d2d8cb Allow unknown JavaDoc tags to not warn about @hide.
Bug: 27208696
Change-Id: I4a23abbe2bde4aad817e5cc475d7ecc5f8af54e8
2016-02-17 14:37:06 -08:00
Mitchell Wills
3e2dff238f Merge "Add OuterTypeFilename rule to Checkstyle" into nyc-dev 2016-02-12 01:08:22 +00:00
Mitchell Wills
e524e6070b Add OuterTypeFilename rule to Checkstyle
This also requires modifying the logic to create temporary files so that
the filename is the same as that in source tree.

Bug: 27109166
Change-Id: I73f2406d5c85d45b0b259f0fd7dd081e44df029c
2016-02-11 16:59:56 -08:00
Aurimas Liutikas
8820526415 Update the message for Checkstyle header warning.
Bug: 27137275
Change-Id: I22f2a83153726457b78a950cb524c128b506b266
2016-02-12 00:48:24 +00:00
Aurimas Liutikas
9b1ba578d7 Add new rules to Checkstyle config.
Add the following new checks:
- JavadocMethod
- MissingDeprecated
- MissingOverride
- OneTopLevelClass
- StringLiteralEquality
- ArrayTypeStyle
- RedundantModifier
- NewlineAtEndOfFile

Bug: 27051781
Change-Id: I4d34278f73ee821cd6cfea705cf949881eaebfc2
2016-02-08 22:29:03 +00:00
Aurimas Liutikas
99451e5b13 Skip JavaDoc checks for Java tests classes
Bug: 26862656
Change-Id: I708ee552154796ece6655db8f9f3157a2e9f3ba5
2016-01-29 13:10:01 -08:00
Aurimas Liutikas
49342a6760 Allow both (c) and (C) in the copyright header.
Bug: 26818467
Change-Id: Iec1a17ecad3e6853d318e907596ed3ae29208902
2016-01-27 10:25:18 -08:00
Aurimas Liutikas
2d59cfb992 Add support for running Checkstyle on a given SHA-1.
Usage e.g.: ./checkstyle.py -s 3aca02ca91816a86febb5ed6e380ec2122adea47

Additionally this CL adds a pre-push script that can be used a git
hook to run Checkstyle on 'repo upload'

Bug: 25852971
Change-Id: Ia00d48df80b2b024de0899d9590868016c5b7bf0
2016-01-25 17:16:28 -08:00
Aurimas Liutikas
23e2d4b3eb Add new two new rules to Checkstyle.
- Add Android copyright header check

- Add comment suppression filter rule to enable suppressing indentation check
Usage:
// CHECKSTYLE:OFF IndentationCheck
  Code.With();
    Bad = Indentation;
// CHECKSTYLE:ON IndentationCheck

Bug: 26747466
Change-Id: I837d7bde1fd85250678a3aba66309043bfc324b1
2016-01-25 11:25:29 -08:00
Aurimas Liutikas
a0e889762d Checkstyle handling when all lines are deleted.
It is valid to have empty modified_lines list for files
that only contain deletions. In such case we should skip
all the errors except for forced rules.

Updated the test to match the expectation.

Change-Id: I6993968b882fb6fbe2ba1f63f3b6879c3308ff34
2016-01-21 14:43:12 -08:00
Aurimas Liutikas
9cd6eaacba Update Checkstyle rules to better match the style guide.
- Correct import order.

Bug: 25852971

Change-Id: I6addc06f7bb91df3d9d011807b5688b5aeba0a0d
2015-12-18 15:10:14 -08:00
Aurimas Liutikas
6b82b75c69 Allow to run checkstyle with untracked files present.
Additionally, this CL adds basic tests.

Bug: 25852971

Change-Id: Ia8a62e0d49428e1d933d2cef832c977e62f9c614
(cherry picked from commit 55e7480eff)
2015-12-18 00:54:02 +00:00
Aurimas Liutikas
4e8bad8045 Fix a crash when a brand new file is added.
Checkstyle.py was not handling additions of new files resulting in
a crash. For new files git.modified_lines() returns None. Added code
handles that case.

Bug: 25852971
Change-Id: I91e2b8c92581ec9e89bcbbcd2d274f56c791f3a9
(cherry picked from commit 5b87dbad0c)
2015-12-18 00:53:20 +00:00
Aurimas Liutikas
1fc79c2192 Add a script that allows developers to run checkstyle.
Allow developers to run Java style check in two ways.

Specific file:
checkstyle.py -f path/to/file/View.java

Lines modified in the latest commit:
checkstyle.py

Review moved from https://googleplex-android-review.googlesource.com/#/c/818813/
due to move from packages/experimental to development/tools

Bug: 25852971
Change-Id: Ibcf9d80644f2938828b21e8f50ab0d6f39c286b0
(cherry picked from commit 96f27d0960)
2015-12-18 00:52:35 +00:00