terryyin / lizard

A simple code complexity analyser without caring about the C/C++ header files or Java imports, supports most of the popular languages.
Other
1.81k stars 246 forks source link

Add "--short" option, print in warnings in red or green #359

Open bzgec opened 1 year ago

bzgec commented 1 year ago
  1. Add "--short" option prints only warnings and total summary.

  2. Print warnings string:

    • red (threshold exceeded) - !!!! Warnings (cyclomatic_complexity > 15 or length > 1000 or nloc > 1000000 or parameter_count > 100) !!!! (problematic functions are not printed in red)
    • green (no threshold exceeded) - No thresholds exceeded (cyclomatic_complexity > 15 or length > 1000 or nloc > 1000000 or parameter_count > 100)

Missing "--short" option tests

terryyin commented 1 year ago

Hi @bzgec thanks for the pull request and sorry for the late response. Do you have test for "--short" option now?

bzgec commented 1 year ago

Are tests from 02da78e enough?

terryyin commented 1 year ago

Hi @bzgec thanks for the test. I have some comments on the test and solution. Some of them are preventive unless my assumptions are wrong.

  1. I think it's an improvement to split print_and_save_modules into save_modules and save_modules. But save_modules seems to be a method that is blocking, rather than continuous yielding. The behaviour of lizard will be very different after this change.
  2. Since the change is mainly adding one if, having one new test is ok. However, assertNotEqual is something I will try my best to avoid. It's too easy to pass and too hard to fail, especially when you are asserting a very specific thing. I find the project so far has 0 assertNotEqual.
bzgec commented 1 year ago

Ok, so for number 2 this should be better? - 51151e4

Did I understand correctly what you had in mind for the number 1? - ed131da