summaryrefslogtreecommitdiff
path: root/util/style/verifiers.py
AgeCommit message (Collapse)Author
2017-02-10misc: Update #!env calls for python to explicit versionJason Lowe-Power
In some newer Linux distributions, env python default to Python 3.0. This patch explicitly uses "python2" instead of just "python" for all scripts that use #! Reported-by: Sanchayan Maity <maitysanchayan@gmail.com> Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
2016-11-25util: git pre-commit hook to check staged filesRekai Gonzalez Alberquilla
This patch updates the git-pre-commit hook to check the files as they will be after the commit, instead of as they are currently, this way we prevent the undesired situation: - unstylish modification of a file - stage said file for commit - try to commit and fail due to style - fix style, forgetting staging changes - try to commit and fail, as although the changes staged are not styly, the current content of the file is. Change-Id: I5cc3f783375d9e4162e310e176103ebbf0a59023 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> [andreas.sandberg@arm.com: Rebased ontop of latest gem5]
2016-08-03style: Make the style fixers safeJason Lowe-Power
Adds a wrapper to the fix functions of the verifiers. This wrapper first copies the original file to a backup file, then performs the fix. If an error occurs, the backup file is used to restore the original file. Also fixed a line-length error in verifiers.py
2016-07-01style: Fix incorrect references style verifiersAndreas Sandberg
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-06-20style: catch trailing white spaces in make and dts filesGabor Dozsa
Change-Id: I2a4f1893919660e51599902b972a6f3f5717e305 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
2016-06-02style: remove extra newline from white space verifier fix methodGabor Dozsa
Change-Id: I7bce7d1cb04efe20d31445eb67ea5ffd2a4a41f4 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
2016-04-18style: Fix Python 2.6 compatibilityAndreas Sandberg
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-03-30style: Change maximum line length to 79 charactersAndreas Sandberg
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-30style: Add a control character checkerAndreas Sandberg
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-30style: Refactor the style checker as a Python packageAndreas Sandberg
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