-
Notifications
You must be signed in to change notification settings - Fork 17
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
Fix license check #28
Conversation
Signed-off-by: Lucas Meneghel Rodrigues <lucas.rodrigues@profitbricks.com>
The current code has a bug reporting license check when --fix is not passed. Let's fix it and also properly report when the license check has failed. Signed-off-by: Lucas Meneghel Rodrigues <lookkas@gmail.com>
Add a new option --no-license-check to checkall, so that people working on non gplv2 projects can simply skip the check. Signed-off-by: Lucas Meneghel Rodrigues <lookkas@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, looks and works good.
result.stdout = stdout | ||
result.stderr = stderr | ||
result.stdout = str(stdout) | ||
result.stderr = str(stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this required? Isn't the return of communicate already string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In py3 it's bytes :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
inspektor/lint.py
Outdated
@@ -63,8 +69,9 @@ def get_opts(self): | |||
pylint_args.append('--disable=%s' % self.ignored_errors) | |||
if self.enabled_errors: | |||
pylint_args.append('--enable=%s' % self.enabled_errors) | |||
pylint_args.append('--reports=no') | |||
if sys.version_info[:2] > (2, 6): | |||
if self._pylint_has_option('--reports'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this should be safest. I'd prefer if we check --reports=<y
to avoid possible clashes with --reports-whatever
or even just example --reports=n
which might be listed in some comment, but that is probably just paranoiac...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough
inspektor/lint.py
Outdated
@@ -45,10 +46,15 @@ def __init__(self, args, logger=logging.getLogger('')): | |||
self.log.info('Pylint enabled : %s' % self.enabled_errors) | |||
else: | |||
self.log.info('Verbose mode, no disable/enable, full reports') | |||
help_result = process.run('pylint --help') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this looks like a global thing and not per-object one. How about moving this to the top and evaluate only once per import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a954a8a that implements the suggestions you made.
if sys.version_info[:2] > (2, 6): | ||
if self._pylint_has_option('--reports='): | ||
pylint_args.append('--reports=no') | ||
if self._pylint_has_option('--score='): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, hopefully they won't change that format 😄
inspektor/lint.py
Outdated
@@ -19,6 +19,9 @@ | |||
from pylint.lint import Run | |||
|
|||
from .path import PathChecker | |||
from .utils import process | |||
|
|||
_PYLINT_HELP_TEXT = process.run('pylint --help').stdout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed this outputs unnecessary Running...
message. Could you please silence it? Apart from that it looks and work good (as far as my old pylint without --score
says)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, sure
Let's use a heuristic that tends to be more reliable instead of looking for python versions or pylint version strings: Check directly the --help output. Since in most py apps the output is auto generated from real command line options, this should be relatively safe. This solves a problem with moving target options such as --score and others. Signed-off-by: Lucas Meneghel Rodrigues <lookkas@gmail.com>
We don't need to print the innocuous bits of information about the commands and applications being initialized. Let's get rid of those methods. Signed-off-by: Lucas Meneghel Rodrigues <lookkas@gmail.com>
On regular mode, only log FAILed files, but on verbose mode, log PASSed as well. Signed-off-by: Lucas Meneghel Rodrigues <lookkas@gmail.com>
For fixable content, whenever we fix a file, let's report on wether the fix was OK or not. This will avoid confusion of people running inspektor and it silently fixing files, and next run the same check will pass (because it was fixed in the previous execution). Signed-off-by: Lucas Meneghel Rodrigues <lookkas@gmail.com>
def clean_up(self, cmd, result, err): | ||
self.LOG.debug('clean_up %s', cmd.__class__.__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, at this point they are useless...
inspektor/path.py
Outdated
if status == 'PASS': | ||
self.log.debug('%s: %s %s', self.label, self.path, status) | ||
elif status == 'FAIL': | ||
self.log.error('%s: %s %s', self.label, self.path, status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Else: custom status or ValueError might unveil typos...
if AUTOPEP8_CAPABLE: | ||
if self.args.fix: | ||
self.log.info('Trying to fix errors with autopep8') | ||
try: | ||
process.run('autopep8 --in-place --max-line-length=%s --ignore %s %s' % (self.args.max_line_length, self.args.disable, path)) | ||
process.run('autopep8 --in-place --max-line-length=%s --ignore %s %s' % (self.args.max_line_length, self.ignored_errors, path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a fix not related to this commit...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I'm a lazy bastard :) Sorry for that one.
Fixes #27, reported by @rdkdd.