Skip to content

add option to suppress pylint report if score is below limit #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion git-pylint-commit-hook
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def main():
parser.add_argument(
'--pylint-params',
help='Custom pylint parameters to add to the pylint command')
parser.add_argument(
'--suppress-report',
action='store_true',
help='Suppress report output if pylint fails')
parser.add_argument(
'--version',
action='store_true',
Expand All @@ -55,7 +59,7 @@ def main():
sys.exit(0)

result = commit_hook.check_repo(
args.limit, args.pylint, args.pylintrc, args.pylint_params)
args.limit, args.pylint, args.pylintrc, args.pylint_params, args.suppress_report)

if result:
sys.exit(0)
Expand Down
12 changes: 11 additions & 1 deletion git_pylint_commit_hook/commit_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def _parse_score(pylint_output):


def check_repo(
limit, pylint='pylint', pylintrc='.pylintrc', pylint_params=None):
limit, pylint='pylint', pylintrc='.pylintrc', pylint_params=None,
suppress_report=False):
""" Main function doing the checks

:type limit: float
Expand All @@ -93,6 +94,8 @@ def check_repo(
:param pylintrc: Path to pylintrc file
:type pylint_params: str
:param pylint_params: Custom pylint parameters to add to the pylint command
:type suppress_report: bool
:param suppress_report: Suppress report if score is below limit
"""
# List of checked files and their results
python_files = []
Expand Down Expand Up @@ -175,6 +178,13 @@ def check_repo(
# Add some output
print('{:.2}/10.00\t{}'.format(decimal.Decimal(score), status))
if 'FAILED' in status:
if suppress_report:
command.append('--reports=n')
proc = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, _ = proc.communicate()
print out


Expand Down