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 support for package and module in Pylint #100

Conversation

JeanChristopheMorinPerso
Copy link
Contributor

Add support for package and module in Pylint.

In python, a project can look like:

src
└── package
    ├── __init__.py
    ├── sub_package1
    │   ├── __init__.py
    │   ├── module1.py
    │   └── module2.py
    └── sub_package2
        ├── __init__.py
        ├── module3.py
        └── module4.py

So if a file named __init__.py exists in a folder, python will consider that folder as a package (or sub-package, but it's the same as a package, so no big difference). And any file that ends in .py is called a module.

Since warnings-ng supports package and module, I decided to also add support for them in the pylint parser.

.hasCategory("W0611")
.hasSeverity(Severity.WARNING_NORMAL)
.hasModuleName("module_name_no_package")
.hasPackageName(null);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This specific test fails and I have absolutely no idea why. If anyone have ideas, I'm all ear 👂
I'm not a Java developer, so I might be missing something obvious...

Copy link
Member

Choose a reason for hiding this comment

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

null is not possible. Seems that the parser returns the module name.

Copy link
Member

Choose a reason for hiding this comment

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

null is not allowed, use "-"

@JeanChristopheMorinPerso
Copy link
Contributor Author

PS: I still have to check with other tools than Pylint if what I did is consistent.

}
builder.setModuleName(moduleName);
}

Copy link
Member

Choose a reason for hiding this comment

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

Here you need:

else {
   builder.setPackageName("-").setModuleName("-");
}

Copy link
Member

Choose a reason for hiding this comment

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

The builder is not cleared between warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aaa, that confirms what I was seeing, effectively. I had the impression something wasn't cleared, but didn't knew what it was. I'll adjust this, thanks :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

.hasCategory("W0611")
.hasSeverity(Severity.WARNING_NORMAL)
.hasModuleName("module_name_no_package")
.hasPackageName(null);
Copy link
Member

Choose a reason for hiding this comment

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

null is not allowed, use "-"

@JeanChristopheMorinPerso JeanChristopheMorinPerso force-pushed the dev_pylint_add_package_and_module branch from 01294c3 to 6c12eb1 Compare March 2, 2019 17:54
@codecov
Copy link

codecov bot commented Mar 2, 2019

Codecov Report

Merging #100 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #100      +/-   ##
============================================
+ Coverage     86.45%   86.48%   +0.02%     
- Complexity     1190     1192       +2     
============================================
  Files           159      159              
  Lines          3832     3840       +8     
  Branches        426      428       +2     
============================================
+ Hits           3313     3321       +8     
  Misses          357      357              
  Partials        162      162
Impacted Files Coverage Δ Complexity Δ
...va/edu/hm/hafner/analysis/parser/PyLintParser.java 84% <100%> (+7.52%) 8 <0> (+2) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a117c9f...6c12eb1. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 2, 2019

Codecov Report

Merging #100 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #100      +/-   ##
============================================
+ Coverage     86.45%   86.48%   +0.02%     
- Complexity     1190     1192       +2     
============================================
  Files           159      159              
  Lines          3832     3840       +8     
  Branches        426      428       +2     
============================================
+ Hits           3313     3321       +8     
  Misses          357      357              
  Partials        162      162
Impacted Files Coverage Δ Complexity Δ
...va/edu/hm/hafner/analysis/parser/PyLintParser.java 84% <100%> (+7.52%) 8 <0> (+2) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a117c9f...38f0909. Read the comment docs.

@JeanChristopheMorinPerso JeanChristopheMorinPerso force-pushed the dev_pylint_add_package_and_module branch from d30d72b to 38f0909 Compare March 2, 2019 18:14
@uhafner uhafner merged commit eaadd8b into jenkinsci:master Mar 3, 2019
@JeanChristopheMorinPerso JeanChristopheMorinPerso deleted the dev_pylint_add_package_and_module branch March 3, 2019 17:09
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.

2 participants