Ignore maker notes when parsing EXIF information to improve performance
[joel/kofoto.git] / check.py
1 #! /usr/bin/env python
2
3 import os
4 import sys
5 from optparse import OptionParser
6 import warnings
7 from pylint import lint
8
9 def disable_message(arguments, message_id):
10     arguments.append("--disable-msg=%s" % message_id)
11
12 ######################################################################
13
14 option_parser = OptionParser()
15 option_parser.add_option(
16     "--all",
17     action="store_true",
18     help="perform all checks",
19     default=False)
20 option_parser.add_option(
21     "--all-complexity",
22     action="store_true",
23     help="perform all complexity checks",
24     default=False)
25 options, args = option_parser.parse_args(sys.argv[1:])
26
27 topdir = os.path.dirname(sys.argv[0])
28
29 sys.path.insert(0, os.path.join(topdir, "src/packages"))
30 if len(args) > 0:
31     modules = args
32 else:
33     modules = ["kofoto"]
34
35 normally_disabled_tests = [
36     "C0103", # "Invalid name"
37     "C0111", # "Missing docstring"
38     "I0011", # "Locally disabling ..."
39     "R0201", # "Method could be a function"
40     "R0801", # "Similar lines ..."
41     "W0142", # "Used * or ** magic."
42     "W0212", # "Access to a protected member foo of a client class"
43     "W0511", # "TODO ..."
44     "W0704", # "Except doesn't do anything."
45 ]
46
47 normally_disabled_complexity_tests = [
48     "C0302", # "Too many lines in module"
49     "R0901", # "Too many parent classes."
50     "R0902", # "Too many instance attributes."
51     "R0903", # "Not enough public methods."
52     "R0904", # "Too many public methods."
53     "R0911", # "Too many return statement."
54     "R0912", # "Too many branches."
55     "R0913", # "Too many arguments."
56     "R0914", # "Too many local variables."
57     "R0915", # "Too many statements."
58     "C0301", # "Line too long."
59 ]
60
61 rc_file_location = os.path.join(topdir, "misc/pylintrc")
62 flags = ["--rcfile", rc_file_location]
63 if not options.all:
64     for x in normally_disabled_tests:
65         disable_message(flags, x)
66     if not options.all_complexity:
67         for x in normally_disabled_complexity_tests:
68             disable_message(flags, x)
69
70 lint.Run(flags + modules)