Merge lp:~dobey/ubuntuone-dev-tools/lint-ignores into lp:ubuntuone-dev-tools

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 40
Merged at revision: 37
Proposed branch: lp:~dobey/ubuntuone-dev-tools/lint-ignores
Merge into: lp:ubuntuone-dev-tools
Diff against target: 64 lines (+24/-12)
1 file modified
bin/u1lint (+24/-12)
To merge this branch: bzr merge lp:~dobey/ubuntuone-dev-tools/lint-ignores
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Review via email: mp+67758@code.launchpad.net

Commit message

Add -i,--ignore option to u1lint to ignore paths

Description of the change

You can test by running ./bin/u1trial, and then running ./bin/u1trial -i bin/u1trial, to see that it will no longer print the XXX/TODO/FIXME warning test that is there.

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

I tested this inside the control panel branch and does not seem to work. Command used to try was:

nessita@dali:~/canonical/u1/controlpanel/fix-809363$ ../../devtools/review_lint-ignores/bin/u1lint --ignore ubuntuone/controlpanel/gui/qt/ui/

And I got all the errors from the generated ui files.

review: Needs Fixing
38. By dobey

Make the path or file statement true for the ignored list check

39. By dobey

Check the path against all ignored paths, to deal with path vs file

40. By dobey

Doh, don't use empty default for ignored as it ignores everything

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Works great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/u1lint'
2--- bin/u1lint 2011-04-13 14:44:11 +0000
3+++ bin/u1lint 2011-07-14 17:29:43 +0000
4@@ -123,9 +123,10 @@
5 config.read([PYLINTRC])
6
7 # pylint: disable=E1103
8- return config.get("MASTER", "ignore").split(",")
9+ return [os.path.join(SRCDIR, item) for item in \
10+ config.get("MASTER", "ignore").split(",")]
11 except (TypeError, ConfigParser.NoOptionError):
12- return None
13+ return []
14 # pylint: enable=E1103
15
16 def _group_lines_by_file(data):
17@@ -178,17 +179,20 @@
18 return pyfiles
19
20
21-def main():
22+def main(options=None, args=None):
23 """Do the deed."""
24+ from optparse import OptionParser
25+ usage = '%prog [options]'
26+ parser = OptionParser(usage=usage)
27+ parser.add_option('-i', '--ignore', dest='ignored', default=None,
28+ help='comma-separated paths or files, to ignore')
29+ (options, args) = parser.parse_args()
30+
31 failed = False
32 ignored = _read_pylintrc_ignored()
33-
34- # So that we can match the path correctly
35- if ignored:
36- moreignores = [os.path.join(SRCDIR, item) for item in ignored]
37- ignored.extend(moreignores)
38- else:
39- ignored = []
40+ if options.ignored:
41+ ignored.extend([os.path.join(SRCDIR, item) for item in \
42+ map(str.strip, options.ignored.split(','))])
43
44 if os.environ.get('USE_PYFLAKES'):
45 pylint_args = get_subprocess_start_info('pyflakes')
46@@ -202,8 +206,16 @@
47
48 for path in _find_files():
49 is_build = path.startswith(os.path.join(SRCDIR, "_build"))
50- if path not in ignored and not is_build:
51- pylint_args.append(path)
52+ is_ignored = False
53+ if path in ignored:
54+ continue
55+ for ignored_path in ignored:
56+ if path.startswith(ignored_path):
57+ is_ignored = True
58+ break
59+ if is_build or is_ignored:
60+ continue
61+ pylint_args.append(path)
62
63 sp = subprocess.Popen(pylint_args,
64 bufsize=4096, stdout=subprocess.PIPE)

Subscribers

People subscribed via source and target branches

to all changes: