AstuteSource / chasten

:dizzy: Chasten Uses XML and XPATH to Check a Python Program's AST for Specified Patterns!
https://pypi.org/project/chasten/
GNU General Public License v2.0
7 stars 8 forks source link

feat: Add total count for checks #104

Closed CalebKendra closed 11 months ago

CalebKendra commented 11 months ago

Previously, when you used the analyze command of chasten you got an output of: 277347188-e5c7bdb0-b184-423b-acb9-5e9c6db31492 This check gives a general overview of what checks passed and didn't, but it would be a lot easier to look at this text if the total amount of checks that passed and the total amount of instances in each check were found were included in the output. This PR gives the output: Screenshot from 2023-11-01 14-30-58 This gives off the total amount of matches in each check, as well as the total amount of checks passed out of the total amount of checks.

boulais01 commented 11 months ago

@CalebKendra is this complete and ready for review?

CalebKendra commented 11 months ago

@CalebKendra is this complete and ready for review?

Not yet, have to pass test cases, It will be ready by today hopefully

simojo commented 11 months ago

@CalebKendra would you be willing to paste an example output using this feature?

CalebKendra commented 11 months ago

@CalebKendra would you be willing to paste an example output using this feature?

A pasted example as in this?

poetry run chasten analyze lazytracker         --config /home/caleb/.config/chasten         --search-path /home/caleb/Allegheny/CMP203/lazytracker         --save-directory /home/caleb/Allegheny/CMP203/lazytracker 

This command with the base config file will produce:

💫 chasten: Analyze the AST of Python Source Code
🔗 GitHub: https://github.com/gkapfham/chasten

✨ Configuration directory: /home/caleb/.config/chasten

✨ Validated /home/caleb/.config/chasten/config.yml? Yes
✨ Validated /home/caleb/.config/chasten/checks.yml? Yes

✨ Analyzing Python source code in: /home/caleb/Allegheny/CMP203/lazytracker

🎉 Performing 5 check(s):

  ✓ id: 'C001', name: 'class-definition', pattern: './/ClassDef', min=1, max=10
    • /home/caleb/Allegheny/CMP203/lazytracker/lazytracker/lazytracker.py - 1 matches
   = 1 total matches

  ✗ id: 'F001', name: 'all-function-definition', pattern: './/FunctionDef', min=1, max=10
    • /home/caleb/Allegheny/CMP203/lazytracker/tests/test_lazytracker.py - 6 matches
    • /home/caleb/Allegheny/CMP203/lazytracker/tests/test_tracked.py - 2 matches
    • /home/caleb/Allegheny/CMP203/lazytracker/lazytracker/lazytracker.py - 6 matches
    • /home/caleb/Allegheny/CMP203/lazytracker/lazytracker/tracked.py - 3 matches
   = 17 total matches

  ✗ id: 'F002', name: 'non-test-function-definition', pattern: './/FunctionDef[not(contains(@name, "test_"))]', min=1, max=10
    • /home/caleb/Allegheny/CMP203/lazytracker/tests/test_lazytracker.py - 2 matches
    • /home/caleb/Allegheny/CMP203/lazytracker/lazytracker/lazytracker.py - 6 matches
    • /home/caleb/Allegheny/CMP203/lazytracker/lazytracker/tracked.py - 3 matches
   = 11 total matches

  ✓ id: 'CL001', name: 'single-nested-if', pattern: './/FunctionDef/body//If', min=1, max=10
    • /home/caleb/Allegheny/CMP203/lazytracker/lazytracker/lazytracker.py - 1 matches
    • /home/caleb/Allegheny/CMP203/lazytracker/lazytracker/tracked.py - 7 matches
   = 8 total matches

  ✗ id: 'CL002', name: 'double-nested-if', pattern: './/FunctionDef/body//If[ancestor::If and not(parent::orelse)]', min=1, max=10
   = 0 total matches

💻 3 / 5 checks passed (60.0%)

😓 At least one check did not pass.
simojo commented 11 months ago

Looks good to me. Thanks.

laurennevill commented 11 months ago

There are some conflicting files that need to be resolved before this can be merged