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

Danger-warnings not working for pylint json report #29

Open
grzegorzprzybyla-silvair opened this issue Aug 2, 2019 · 4 comments
Open

Comments

@grzegorzprzybyla-silvair

Hi,
I would like to introduce danger-warnings into my python project.
But it seems like there is something wrong with pyLint json parser.
I've setup demo env to reproduce this issue:

Env:

  • danger (6.0.9)
  • danger-plugin-api (1.0.0)
  • danger-warnings (0.1.0)
  • PyLint 2.3.1

demo project can be found here:
https://github.com/grzegorzprzybyla-silvair/python_demo

After executing bundle exec danger local, you can see following output:

Info:

+------------------+--------------------------------------------------------------------+
| Danger v6.0.9 |
| DSL Attributes |
+------------------+--------------------------------------------------------------------+
| violation_report | |

status_report
scm_provider github
added_files File2.py
deleted_files #Danger::FileList:0x00007fd59a3c84b8
modified_files #Danger::FileList:0x00007fd59a3c8238
renamed_files []
lines_of_code 6
deletions 0
insertions 6
commits 6c926b0f7b9329323cd1a1efb404c86b77d1d9c1
tags #Enumerator:0x00007fd599a29f60
diff diff --git a/File2.py b/File2.py
new file mode 100644
index 0000000..375f728
--- /dev/null
+++ b/File2.py
@@ -0,0 +1,6 @@
+class File2:
+ def init(self):
+ pass
+
+ def test():
+ pass
\ No newline at end of file
pr_body
pr_author grzegorzprzybyla-silvair
pr_labels []
branch_for_base master
branch_for_head feature/pr_1
base_commit 7a9e6cbf153d80c1eda7d8881b6b8de56151b270
head_commit 6c926b0f7b9329323cd1a1efb404c86b77d1d9c1
api Octokit::Client
mr_title Add File2
mr_body
mr_author grzegorzprzybyla-silvair
mr_labels []
pr_json [Skipped JSON]
mr_json [Skipped JSON]
pr_diff [Skipped Diff]
review #Danger::RequestSources::GitHubSource::Review:0x00007fd59a4027a8
pr_title Add File2
filter
fail_error
inline
--- ---
SCM Danger::GitRepo
Source Danger::LocalGitRepo
Requests Danger::RequestSources::GitHub
Base Commit commit 7a9e6cbf153d80c1eda7d8881b6b8de56151b270
Author: Grzegorz Przybyła grzegorz.przybyla@silvair.com
Date: Fri Aug 2 12:56:52 2019 +0200
Inital commit
Head Commit commit 6c926b0f7b9329323cd1a1efb404c86b77d1d9c1
Author: Grzegorz Przybyła grzegorz.przybyla@silvair.com
Date: Fri Aug 2 13:41:08 2019 +0200
Add File2
+------------------+--------------------------------------------------------------------+

I've check and for bandit generated json it's working.
PyLint report is committed into project, so there are warnings inside

@Kyaak
Copy link
Owner

Kyaak commented Aug 5, 2019

Hi @grzegorzprzybyla-silvair
Thanks for using my plugin.

As in Parsers documented, I only support the PyLint format parseable. Json formatted report is not working for this report. Maybe the file format any is misleading.

So the easiest and fastest fix is to use parseable formatter:
--output-format=parseable

If you use Jenkins to test your code, may I introduce you to danger-warnings_next_generation - an easy to use all in one solution.

@Kyaak
Copy link
Owner

Kyaak commented Aug 13, 2019

@grzegorzprzybyla-silvair
Did this help you to get the plugin running?

@grzegorzprzybyla-silvair
Copy link
Author

I will check this :)

@grzegorzprzybyla-silvair
Copy link
Author

Ok, even If I have change the output for my pylint:
pylint example.py --output-format=parseable >> reports/pylint
And in danger file I've changed:

warnings.report(          
  parser: :pylint,
  file: 'reports/pylint',
  filter: false
)

pylint output:

************* Module example
example.py:2: [C0303(trailing-whitespace), ] Trailing whitespace
example.py:3: [C0303(trailing-whitespace), ] Trailing whitespace
example.py:4: [W0312(mixed-indentation), ] Found indentation with tabs instead of spaces
example.py:5: [W0312(mixed-indentation), ] Found indentation with tabs instead of spaces
example.py:9: [W0312(mixed-indentation), ] Found indentation with tabs instead of spaces
example.py:10: [W0312(mixed-indentation), ] Found indentation with tabs instead of spaces
example.py:1: [C0111(missing-docstring), ] Missing module docstring
example.py:2: [C0111(missing-docstring), Test] Missing class docstring
example.py:4: [E0213(no-self-argument), Test.__init__] Method should have "self" as first argument
example.py:5: [E0602(undefined-variable), Test.__init__] Undefined variable 'self'
example.py:2: [R0903(too-few-public-methods), Test] Too few public methods (0/2)
example.py:8: [E0602(undefined-variable), ] Undefined variable '__main__'
example.py:9: [C0103(invalid-name), ] Constant name "test" doesn't conform to UPPER_CASE naming style
example.py:10: [E1101(no-member), ] Instance of 'Test' has no 'bar' member

----------------------------------------------------------------------
Your code has been rated at -40.00/10 (previous run: -40.00/10, +0.00)

danger local is still not returning any issues

danger local
Running your Dangerfile against this PR - https://github.com/grzegorzprzybyla-silvair/python_demo/pull/1
Turning on --verbose

Info:

+------------------+--------------------------------------------------------------------+
|                                     Danger v6.0.9                                     |
|                                    DSL Attributes                                     |
+------------------+--------------------------------------------------------------------+
|    status_report |                                                                    |
| violation_report |                                                                    |
|              --- | ---                                                                |
|     scm_provider | github                                                             |
|      added_files | File2.py                                                           |
|             diff | diff --git a/File2.py b/File2.py                                   |
|                  | new file mode 100644                                               |
|                  | index 0000000..375f728                                             |
|                  | --- /dev/null                                                      |
|                  | +++ b/File2.py                                                     |
|                  | @@ -0,0 +1,6 @@                                                    |
|                  | +class File2:                                                      |
|                  | +	def __init__(self):                                              |
|                  | +		pass                                                            |
|                  | +                                                                  |
|                  | +	def test():                                                      |
|                  | +		pass                                                            |
|                  | \ No newline at end of file                                        |
|    deleted_files | #<Danger::FileList:0x00007ff04041efa0>                             |
|   modified_files | #<Danger::FileList:0x00007ff04041e8e8>                             |
|    renamed_files | []                                                                 |
|    lines_of_code | 6                                                                  |
|        deletions | 0                                                                  |
|       insertions | 6                                                                  |
|          commits | 6c926b0f7b9329323cd1a1efb404c86b77d1d9c1                           |
|             tags | #<Enumerator:0x00007ff03e89a4c8>                                   |
|        mr_author | grzegorzprzybyla-silvair                                           |
|        mr_labels | []                                                                 |
|              api | Octokit::Client                                                    |
|          pr_json | [Skipped JSON]                                                     |
|           review | #<Danger::RequestSources::GitHubSource::Review:0x00007ff040205a98> |
|         pr_title | Add File2                                                          |
|          pr_body |                                                                    |
|        pr_author | grzegorzprzybyla-silvair                                           |
|        pr_labels | []                                                                 |
|  branch_for_base | master                                                             |
|  branch_for_head | feature/pr_1                                                       |
|      base_commit | 7a9e6cbf153d80c1eda7d8881b6b8de56151b270                           |
|      head_commit | 6c926b0f7b9329323cd1a1efb404c86b77d1d9c1                           |
|          mr_json | [Skipped JSON]                                                     |
|          pr_diff | [Skipped Diff]                                                     |
|         mr_title | Add File2                                                          |
|          mr_body |                                                                    |
|       fail_error |                                                                    |
|           filter |                                                                    |
|           inline |                                                                    |
|              --- | ---                                                                |
|              SCM | Danger::GitRepo                                                    |
|           Source | Danger::LocalGitRepo                                               |
|         Requests | Danger::RequestSources::GitHub                                     |
|      Base Commit | commit 7a9e6cbf153d80c1eda7d8881b6b8de56151b270                    |
|                  | Author: Grzegorz Przybyła <grzegorz.przybyla@silvair.com>          |
|                  | Date:   Fri Aug 2 12:56:52 2019 +0200                              |
|                  |                                                                    |
|                  |     Inital commit                                                  |
|      Head Commit | commit 6c926b0f7b9329323cd1a1efb404c86b77d1d9c1                    |
|                  | Author: Grzegorz Przybyła <grzegorz.przybyla@silvair.com>          |
|                  | Date:   Fri Aug 2 13:41:08 2019 +0200                              |
|                  |                                                                    |
|                  |     Add File2                                                      |
+------------------+--------------------------------------------------------------------+

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

No branches or pull requests

2 participants