1

By Running the pylint --load-plugins pylint_django ~/src/github.com/<repo>/ ||, it creates this very useful table displaying all the messages types, as well as how many of each my codebase has. As well as a WHOLE LOT of other information.

pylint messages table

My question is, how can I get pylint to only output this table, as well as populate the previous and difference columns? I'd love to have a set of commands that runs this table against the tip of Master (previous), and my current branch.

Something like

### pseudocode
pylint table <git hash of previous> <git hash of current> 
Andrew
  • 11
  • 2
  • You can perhaps just run `pylint table HEAD~ HEAD`. Anywhere you can use a hash ID, you can use a name like `HEAD` or a branch name, or the same thing suffixed with any of Git's revision modifiers. Git doesn't really have anything to do with generating the table though; that's entirely up to the program you run. – torek Oct 26 '21 at 21:20
  • Sorry I wasn't specific. Pylint Table is NOT a real command, it's my dream command, if that makes sense. – Andrew Oct 26 '21 at 21:22
  • Oh, I see. Well, if you have to write a program, you'll probably want to take arbitrary strings and run `git clone` and/or `git checkout` and/or `git worktree add` to extract those commits. That's much more a question about using Git than it is about writing Python programs, unless you intend to do each Git operating using pygit. But you'll need to focus on something specific to make this appropriate for StackOverflow. – torek Oct 26 '21 at 21:32

1 Answers1

0

If you launch pylint twice in the same environment with the report option activated (and have permission to write file in this environment) then simply launching pylint -r y --load-plugins pylint_django ~/src/github.com/<repo>/ at commit that interest you should work.

First run:

Raw metrics
-----------

+----------+-------+------+---------+-----------+
|type      |number |%     |previous |difference |
+==========+=======+======+=========+===========+
|code      |14276  |53.52 |NC       |NC         |
+----------+-------+------+---------+-----------+
|docstring |6904   |25.88 |NC       |NC         |
+----------+-------+------+---------+-----------+
|comment   |1887   |7.07  |NC       |NC         |
+----------+-------+------+---------+-----------+
|empty     |3606   |13.52 |NC       |NC         |
+----------+-------+------+---------+-----------+

Second run after adding an issue voluntarily:

Raw metrics
-----------

+----------+-------+------+---------+-----------+
|type      |number |%     |previous |difference |
+==========+=======+======+=========+===========+
|code      |14277  |53.52 |14276    |+1.00      |
+----------+-------+------+---------+-----------+
|docstring |6904   |25.88 |6904     |=          |
+----------+-------+------+---------+-----------+
|comment   |1887   |7.07  |1887     |=          |
+----------+-------+------+---------+-----------+
|empty     |3606   |13.52 |3606     |=          |
+----------+-------+------+---------+-----------+

Ie you can do:

git checkout hash1
pylint -r y ...
git checkout hash2
pylint -r y ...
Pierre.Sassoulas
  • 3,733
  • 3
  • 33
  • 48