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

Add Pylint logs #512

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Add Pylint logs #512

wants to merge 6 commits into from

Conversation

michalfrak
Copy link

Pylint logs are shown in shell. Break of building in case of too low Pylint score or too high Pylint decrease added. Also build break on Pylint errors with option to switch it off.

@coveralls
Copy link

coveralls commented Oct 18, 2017

Coverage Status

Coverage increased (+0.2%) to 75.185% when pulling 3d82cc7 on michalfrak:master into d0f8f80 on pybuilder:master.

Copy link
Contributor

@AlexeySanko AlexeySanko left a comment

Choose a reason for hiding this comment

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

Hi.

Commits 6 - good sence to squash all branch commits into one before merge

Copy link
Contributor

@AlexeySanko AlexeySanko left a comment

Choose a reason for hiding this comment

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

Great job. Just a couple suggestions for sources.

errors_info = ''
warnings = 0
warnings_info = ''
show_info_messages = project.get_property('pylint_show_info_messages')
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need separated properties pylint_show_info_messages and pylint_show_warning_messages? Could we use global project property project.get_property('verbose') instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

With verbose you can not decide if you want to see only warnings, moreover with verbose you will see a lot of other logs. I think it is good to have separate configuration for this.
What do you think about this @AlexeySanko ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, @maciejpolanczyk
I used idea that pylint shows all issues anyway. And verbose mode supposes that output could be big. 😁

Copy link
Contributor

Choose a reason for hiding this comment

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

pylint shows all issues in report file. I would like to have possibility to show only warnings or only infos from pylint on console as output from pybuilder without big output which will be created by 'verbose' from other plugins and pybuiilder. It will be easy to read them and I will not have to go to report file to find out what went wrong.
What do you think about it @AlexeySanko ? Or should we abandon this idea because it is not consistent with unit tests execution?

Copy link
Contributor

Choose a reason for hiding this comment

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

On the other hand - cause of report parsing You can manage different type of issues. Why not?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean all logger.info in this file or only the one which shows infos from pylint?
We decided for logger.info base on other plugins which use this level for printing information which should be print in regular run (without verbose)

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -44,4 +45,63 @@ def execute_pylint(project, logger):
logger.info("Executing pylint on project sources")

command_and_arguments = ["pylint"] + project.get_property("pylint_options")
execute_tool_on_modules(project, "pylint", command_and_arguments, True)
pylint_output_file_path = execute_tool_on_modules(project, "pylint", command_and_arguments, True)[1]
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to use

execute_tool_on_source_files(project, "pylint", command_and_arguments, include_test_sources=?)

We will get two advantages:

  1. provide possibility to include test_sources with property pylint_include_test_sources
  2. remove possible problems with pylint: execute_tool_on_modules uses discover_modules which returns list of all packages AND modules. For example, I have package pckg with modules a, b and c. discover_modules returns list: [ 'pckg', 'pckg.a', 'pckg.b', 'pckg.c'] and pylint will report problem with duplicated code into files (it will parse pckg.a twice).

warnings_info = ''
show_info_messages = project.get_property('pylint_show_info_messages')
show_warning_messages = project.get_property('pylint_show_warning_messages')
for line in file_content:
Copy link
Contributor

Choose a reason for hiding this comment

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

If we parse pylint results I think that more suitable is JSON format --output-format=json instead of raw text. It's more resistant to future changes, isn't?

Example, of JSON output

[
    {
        "message": "Missing module docstring", 
        "obj": "", 
        "column": 0, 
        "path": "src/main/python/some_lib/model.py", 
        "line": 1, 
        "type": "convention", 
        "symbol": "missing-docstring", 
        "module": "some_lib.model"
    }, 
    {
        "message": "Invalid constant name \"lc\"", 
        "obj": "", 
        "column": 0, 
        "path": "src/main/python/some_lib/model.py", 
        "line": 12, 
        "type": "convention", 
        "symbol": "invalid-name", 
        "module": "some_lib.model"
    }
...

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, JSON report doesn't provide scores. :(

'Pylint ratio: {} / Pylint change: {}'.format(pylint_score, pylint_change) + errors_info + warnings_info
)

if errors > 0 and project.get_property('pylint_break_build_on_errors'):
Copy link
Contributor

Choose a reason for hiding this comment

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

flake8 and frosted use *_break_build property. I suggest to do the same: use pylint_break_build

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @AlexeySanko thanks for quick response to PR. In case of pylint we have a little different situation. In this plugin we assumed we can fail from different reasons:

  • errors in output
  • pylint score too low
  • pylint change of score (for example from 9.0 to 8.5) is too big
    This is why we used 'pylint_break_build_on_errors' for the first case.
    Using 'pylint_break_build' suggests this is global brake/not brake which is not true in this case.
    Do you agree with this approach? Do you have suggestion for better naming in this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, @maciejpolanczyk
I thought that You will not support RP and created external plugin pybuilder_pylint_extended.
I used idea that plugin has to break build on errors and fatals anyway - otherwise You can disable and do not use plugin. Errors are errors and have to be fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, we will change it to work as you described.

warnings = 0
warnings_info = ''
show_info_messages = project.get_property('pylint_show_info_messages')
show_warning_messages = project.get_property('pylint_show_warning_messages')
Copy link
Contributor

Choose a reason for hiding this comment

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

I could set show_info_messages = True and show_info_messages = True when verbose and debug are true. What do you think about it @AlexeySanko ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, @maciejpolanczyk
Good idea. Thanks!

warnings += 1

if show_info_messages and (line.startswith('C:') or line.startswith('R:')):
logger.info('Pylint: Module %s: ' % module_name + line)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, @maciejpolanczyk
Info - summary and common build information. More looks like that convensions and refactorings should be pass to logger.warn too.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, will fix this.

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

4 participants