Commit graph

12 commits

Author SHA1 Message Date
Andreas Sandberg
57e3f40100 style: Fix incorrect references style verifiers
The style checker for spacing around control statements (ControlSpace)
and the whitespace checker (Whitespace) didn't refer to some of their
configuration variables correctly. This changeset fixes those issues.

Reported-by: Jason Lowe-Power <power.jg@gmail.com>

--HG--
extra : amend_source : 05d82d27d4c42aacd78b514d3ca35ca5744164bb
2016-07-01 15:35:52 +01:00
Gabor Dozsa
ddfc4c4593 style: catch trailing white spaces in make and dts files
Change-Id: I2a4f1893919660e51599902b972a6f3f5717e305
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
2016-06-20 14:49:52 +01:00
Gabor Dozsa
21f971e4d1 style: remove extra newline from white space verifier fix method
Change-Id: I7bce7d1cb04efe20d31445eb67ea5ffd2a4a41f4
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
2016-06-02 10:48:20 +01:00
Andreas Sandberg
95d6d9321f style: Move the last bits of file_types.py to the style package
The commit that refactored the style checkers into a new Python
package (style: Refactor the style checker as a Python package)
accidentally left a fragment of file_types.py in the old location
(util/style.py). This was caused by a race between the commit that
moved the file and Nate's commit that added a copyright header to the
file.

This commit moves the last fragment (the copyright header) and removes
the old file.

Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>

--HG--
extra : amend_source : 946f1f6fee034ae79bd50ea7dfc3299a60f070c0
2016-06-02 10:37:16 +01:00
Curtis Dunham
3f24000d46 style: ignore test data in style checks
Change-Id: If797eaf3842b5c1604942bb60f091800ee814a2a
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
2016-04-28 15:19:58 +01:00
Curtis Dunham
8be5717a02 style: improve compatibility with old git versions
Older versions of git need the '=' to connect --diff-filter to
its argument.

Change-Id: Ic62057567db061684be88a7c2d80a6a5d4c11dcf
2016-04-28 15:17:50 +01:00
Andreas Sandberg
f819518158 style: Fix Python 2.6 compatibility
The style checker code needs to disable autojunk when diffing source
files using Python's difflib. Support for this was only introduced in
Python 2.7, which leads to a TypeError exception on older Python
version. This changeset adds a fallback mechanism for old Python
versions.
2016-04-18 10:31:38 +01:00
Andreas Sandberg
bdbd67f2cb style: Change maximum line length to 79 characters
The old style guide used to mandate 78 characters as the maximum line
length to accommodate traditional diffs on 80-column terminals. This
is an uncommon use case and it has therefore been decided (see email
thread on gem5-dev [1]) that a maximum length of 79-characters makes
more sense.

[1] http://comments.gmane.org/gmane.comp.emulators.m5.devel/29789

Signed-off-by: Andreas Sandberg <aandreas.sandberg@arm.com>
Reviewed-by: Brandon Potter <brandon.potter@amd.com>

--HG--
rename : util/style.py => util/hgstyle.py
extra : rebase_source : 63efcc4da2585ef8c323d6f322736f64d71742f8
2016-03-30 15:36:50 +01:00
Andreas Sandberg
22ff270b17 style: Add repository helper functions
Add an AbstractRepo class and implementations for git and Mercurial
that provide a common interface to query repository status for style
checkers. The class defines the interfaces to list modified files that
are about to be committed and methods to identify changed regions.

Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Curtis Dunham <curtis.dunham@arm.com>
Reviewed-by: Steve Reinhardt <steve.reinhardt@amd.com>

--HG--
rename : util/style.py => util/hgstyle.py
extra : rebase_source : da1f482a1ecac2b0be437dc400b4a66bd3b301cc
2016-03-30 15:33:04 +01:00
Andreas Sandberg
74f62c784d style: Remove style validators
Style validators provide a subset of the style verifier functionality
and are only exposed through the "hg m5format" command. This
functionality seems to be both redundant and unused.

Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>

--HG--
extra : rebase_source : f4847ac3ddc86f6684565b65a942e04979972a7b
2016-03-30 15:32:17 +01:00
Andreas Sandberg
a05efc77be style: Add a control character checker
Add a style checker that verifies that source code doesn't contain
non-printable (control) characters. The only allowed control
characters are:

  * 0x0a / \n: New line
  * 0x09 / \t: Tab (the whitespace checker enforces no-tabs for C/C++ files)

Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Brandon Potter <brandon.potter@amd.com>

--HG--
extra : rebase_source : 9ba3e2971774a7b3d73cda34bbee1f19c4add746
2016-03-30 15:31:23 +01:00
Andreas Sandberg
2580fcd9d7 style: Refactor the style checker as a Python package
Refactor the style checker into a Python module that can be reused by
command line tools that integrate with git. In particular:

  * Create a style package in util
  * Move style validators from style.py to the style/validators.py.
  * Move style verifiers from style.py to the style/verifiers.py.
  * Move utility functions (sort_includes, region handling,
    file_types) into the style package
  * Move generic code from style.py to style/style.py.

Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Curtis Dunham <curtis.dunham@arm.com>
Reviewed-by: Steve Reinhardt <steve.reinhardt@amd.com>

--HG--
rename : util/style.py => util/hgstyle.py
rename : util/sort_includes.py => util/style/sort_includes.py
extra : rebase_source : ad6cf9b9a18c48350dfc7b7c77bea6c5344fb53c
2016-03-30 15:30:32 +01:00