Commit Graph

26 Commits

Author SHA1 Message Date
Joe Gordon a44ace3196 Fix pep8 exclude logic for 1.3.3
* With pep8 1.3.3 the exclude logic monkey patch broke causing
  tools/hacking to run on openstack/common code
* Also add .git to exclude list

Fix bug 1086410

Change-Id: Ifc50ac1963c50c338432bbb4b1e15cdf58ed2128
2012-12-06 11:19:17 +02:00
Dan Smith 9471282626 Ban db import from nova/virt
This makes hacking.py complain if someone adds something like:

  from nova import db

into any of the files in nova/virt/* (aside from the fake.py file).
It also removes the rest of the dangling db imports that are no
longer needed.

Yay!

Change-Id: Iba3d53b87e65e33a55f8e5033b5d1d33b28d12f7
2012-11-12 12:37:33 -08:00
Joe Gordon f82e765edb Remove extra print line in hacking.py
Change-Id: If3d5da52a55c1834f4dfa49d817010d314d1403a
2012-10-29 13:15:40 -07:00
Joe Gordon fcefe62547 Change hacking.py N306 to use logical_lines
Only logical lines (does not include comments) should be checked for
alphabetical import order.  This patch changes N306
(imports not in alphabetical order) to run on logical lines not physical lines.

Fixes bug 1071849

Change-Id: Ib2cb92f9eb82aeed1ff5879d3e38c8961b4f06cc
2012-10-26 20:40:36 +00:00
Dan Smith 88f252a3d4 Fix hacking.py naivete regarding lines that look like imports
Right now, any line that starts with "from" (after whitespace
removal) is considered an import line. That assumption leads to
some unsavory parsing and crashing if the line doesn't match
the expected format.

This patch checks to make sure that the word "import" is in the line
as well as starting with "from", which at least gets us a bit closer
to a reasonable assumption.

Fixes bug 1071849

Change-Id: Iab666fcd04a9aaa3a490737a173ee3189b9b8329
2012-10-26 11:39:46 -07:00
Joe Gordon fbc4568eb0 Update tools hacking for pep8 1.2 and beyond
* https://github.com/jcrocholl/pep8/commit/b9f72b16011aac981ce9e3a47fd0ffb1d3d2e085
  broke tools/hacking.py
* Upgrade pep8 to 1.2 and disable the following new tests: E12,E711,E712,E721,E502

Change-Id: I32a8808c6c9cccfedcc4d2a26649333aca1cd713
2012-10-01 16:33:35 -07:00
Joe Gordon 6109970e2a Fix hacking.py git checks to propagate errors
Now when N801 or N802 is hit tools/hacking.py will return -1.

Fix bug 1039697

Change-Id: I9f6950a4396ae82861e5de0e4f3ba8b482c4fdf8
2012-08-22 10:52:05 -07:00
Monty Taylor c1c068bb6b Make missing imports flag in hacking settable.
Change-Id: Ib1ada320588eb42370c9fa2c0eff4eb888258ea5
2012-08-17 13:38:29 -04:00
Joe Gordon 47a1bbe311 Add a 50 char git title limit test to hacking.
* add N802 to hacking.py

Change-Id: I8262531b4b3f8f3a1a2a37679904cf4864cae7b6
2012-08-08 14:53:38 -07:00
Monty Taylor b71e86d4d7 Fix broken pep8 exclude processing.
First of all, our pep8 exclude was excluding openstack, to trap
for not doing pep8 checks on openstack/common, which comes from elsewhere.
But, pep8 strips filenames down to basename when doing exclude checks on
them, which makes no sense. To fix this, grab the two functions from pep8,
fix them, and monkeypatch them from within hacking.py.

Patch has been submitted upstream as:

  https://github.com/jcrocholl/pep8/pull/111

Also, changed the exclude to catch just openstack/common.

Change-Id: If0b18ae828e74203f84a8b6f8b4ba0100b3bbc59
2012-08-03 12:15:44 -05:00
Chris Behrens e6f2e886a4 Replace subprocess.check_output with Popen
The check_output method does not exist in python 2.6

Fixes bug 1029014

Change-Id: I1ee24fa2029f21706924cc19dfcbc41655b022e6
2012-07-26 09:15:09 +00:00
Joe Gordon 7a376fa48b Add git commit message validation to hacking.py
Adds N801: git commit title should provide a description

Change-Id: Ic6334b20f5f06631b7a5579a4d1b2303685463eb
2012-07-20 15:19:15 -07:00
Sean Dague 7b43eaa9d8 modify hacking.py to not choke on the def of _()
recent openstack-common brought in it's own def of _() which trips
up our checking that all _ calls contain a message string.

This explicitly excludes the definition of this in function from
that check.

Fixes LP Bug #1020792.

Change-Id: If647d77a5ae5560935bb2e032331c34b896b8614
2012-07-05 16:59:48 -04:00
Brian Waldon 90a93098a6 Correct typo in tools/hacking.py l18n -> i18n
i18n stands for internationalization, while l10n stands for
localization. l18n stands for nothing.

Change-Id: Iebfe2dcbc12919875c0ecee8aa9223dc107239d7
2012-07-05 09:50:55 -07:00
Zhongyue Luo 61c5597a09 Backslash continuation removal (Nova folsom-2)
Fixes bug #938588

Backslash continuations removal for scripts in bin/, plugin/, and etc.

Change-Id: Idd17048b6e8db6e939946968e011e68da8585b8d
2012-05-31 11:26:37 +08:00
Jenkins 7f910cddc3 Merge "Cleanup tools/hacking using flake8" 2012-05-31 01:50:46 +00:00
Matt Joyce d5cc5fd2f0 Grammar fixes.
Change-Id: Iff3f5765193e0bc98dfc377ee5a9b6f47ae11859
2012-05-29 13:01:57 -07:00
Joe Gordon 6e480708ee Cleanup tools/hacking using flake8
Change-Id: Ia151f265bf62e6704de6cc2f2c01963be9e2dd69
2012-05-24 12:03:37 -07:00
Brian Waldon 317378f742 Update pep8 dependency to v1.1
The latest release of pep8 adds stricter rules for extraneous
whitespace within lines. This patch also addresses these new
violations acoss the codebase.

Change-Id: Ib7e50281870473df1704ed50868c5c2e26bdb02e
2012-05-24 06:59:05 -07:00
Joe Gordon 82e1019edb Number of missing imports should always be shown
In tools/hacking.py

Change-Id: I1219dcc140594be97fc680981a122157fed2e279
2012-04-24 13:00:13 -07:00
Joe Gordon 7ee0d7848d Improved tools/hacking.py
* cleaner output
* fix bug 980009
* Fix N201
* N306: alphabetical order imports
* N401: docstring start
* N402: one line docstring start
* N403: multi line docstring end
* Until fixed, N40* will be disabled by default

Change-Id: I9addafdaa7a1f8fb950e14a5409f661dec6c7b87
2012-04-24 09:29:43 -07:00
Yuriy Taraday 4fe6f839bd Improved localization testing.
Moved localization tests to tools/hacking.py.

Change-Id: I903b90dfb09a46a72b1c64c30301f90661999f5b
2012-04-10 22:01:55 +04:00
Yuriy Taraday f7a6c58d92 HACKING fixes, sqlalchemy fix.
Add exceptions to hacking.py make sqlalchemy stuff legal and prevent
clutter.

Change-Id: I44b100b4c0c4dfcec81beea7aba2d8598d5a08d0
2012-04-09 18:00:40 +04:00
Yuriy Taraday 01a938f7fe HACKING fixes, all but sqlalchemy.
Looks like this fixes all HACKING problems that were around.
Thanks to Dina Belova and Alexander Kovalev for this work.

Change-Id: I8157f0d4890184c1216aab63ef7180ee8b7a184d
2012-03-07 12:51:39 +04:00
Joe Gordon e8bc00eff2 Add assertRaises check to tools/hacking.py as N202
Change-Id: I25113bcc73ff642cae146f0558f319684b4568d0
2012-03-05 14:09:57 -08:00
Joe Gordon 9a08e00548 Add HACKING compliance testing to run_test.sh
Tests so far:
N101 TODO format
N201 Except format
N301 One import per line
N302 import only modules
N303 Invalid Import
N304 Relative Import

Change-Id: I33c021b842e7199b1f5f1f699ea17f7fa5f8ca49
2012-01-24 10:54:17 -08:00