Skip to content
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

Merged
merged 7 commits into from
Aug 9, 2017
Merged

Fix license check #28

merged 7 commits into from
Aug 9, 2017

Conversation

lmr
Copy link
Member

@lmr lmr commented Aug 9, 2017

Fixes #27, reported by @rdkdd.

lmr and others added 3 commits August 9, 2017 14:48
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>
Copy link
Contributor

@ldoktor ldoktor left a 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)
Copy link
Contributor

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?

Copy link
Member Author

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 :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@@ -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'):
Copy link
Contributor

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...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough

@@ -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')
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea!

Copy link
Member Author

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='):
Copy link
Contributor

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 😄

@@ -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
Copy link
Contributor

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, sure

lmr added 4 commits August 9, 2017 22:01
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>
@lmr lmr merged commit 3d5a14a into master Aug 9, 2017
def clean_up(self, cmd, result, err):
self.LOG.debug('clean_up %s', cmd.__class__.__name__)
Copy link
Contributor

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...

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)
Copy link
Contributor

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))
Copy link
Contributor

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...

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants