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.85k stars 250 forks source link

Failing to find files. #83

Closed c0yote closed 8 years ago

c0yote commented 8 years ago

Am I misusing this software? For some reason when providing a path, the application doesn't find source files. I can direct it to specific source files as show below.

No files analyzed against directory:

C:\workspace\machina>lizard .\
================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
--------------------------------------------------------------
0 file analyzed.
==============================================================
NLOC    Avg.NLOC AvgCCN Avg.ttoken  function_cnt    file
--------------------------------------------------------------

=================================================================
!!!! Warnings (CCN > 15 or arguments > 100 or length > 1000) !!!!
================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
==========================================================================================
Total nloc  Avg.nloc  Avg CCN  Avg token  Fun Cnt  Warning cnt   Fun Rt   nloc Rt
------------------------------------------------------------------------------------------
         0         1     0.00       0.00        1            0      0.00    0.00

Analysis against single source file in same directory:

C:\workspace\machina>lizard ex.py
================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
--------------------------------------------------------------
1 file analyzed.
==============================================================
NLOC    Avg.NLOC AvgCCN Avg.ttoken  function_cnt    file
--------------------------------------------------------------
     84      0    0.0         0         0     ex.py

=================================================================
!!!! Warnings (CCN > 15 or arguments > 100 or length > 1000) !!!!
================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
==========================================================================================
Total nloc  Avg.nloc  Avg CCN  Avg token  Fun Cnt  Warning cnt   Fun Rt   nloc Rt
------------------------------------------------------------------------------------------
        84         1     0.00       0.00        1            0      0.00    0.00

Can't get it to work with full paths either.

I got it with a pip install.

terryyin commented 8 years ago

Thanks for reporting, I will look at it asap.

terryyin commented 8 years ago

@c0yote I made a fix (1.9.18). Could you please try it again?

c0yote commented 8 years ago

Sorry, still doesn't work.

Install shows correct version.

C:\workspace\machina>python -m pip install lizard
Collecting lizard
  Using cached lizard-1.9.18.tar.gz
Installing collected packages: lizard
  Running setup.py install for lizard
Successfully installed lizard-1.9.18

Run on directory still doesn't work.

C:\workspace\machina>python -m lizard
================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
--------------------------------------------------------------
0 file analyzed.
==============================================================
NLOC    Avg.NLOC AvgCCN Avg.ttoken  function_cnt    file
--------------------------------------------------------------

=================================================================
!!!! Warnings (CCN > 15 or arguments > 100 or length > 1000) !!!!
================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
==========================================================================================
Total nloc  Avg.nloc  Avg CCN  Avg token  Fun Cnt  Warning cnt   Fun Rt   nloc Rt
------------------------------------------------------------------------------------------
         0         1     0.00       0.00        1            0      0.00    0.00

Run on source file still does.

C:\workspace\machina>python -m lizard ex.py
================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
--------------------------------------------------------------
1 file analyzed.
==============================================================
NLOC    Avg.NLOC AvgCCN Avg.ttoken  function_cnt    file
--------------------------------------------------------------
     84      0    0.0         0         0     ex.py

=================================================================
!!!! Warnings (CCN > 15 or arguments > 100 or length > 1000) !!!!
================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
==========================================================================================
Total nloc  Avg.nloc  Avg CCN  Avg token  Fun Cnt  Warning cnt   Fun Rt   nloc Rt
------------------------------------------------------------------------------------------
        84         1     0.00       0.00        1            0      0.00    0.00

It does work on C++ source directories.

C:\workspace\scrit>python -m lizard
================================================
  NLOC    CCN   token  PARAM  length  location  
------------------------------------------------
      28      4    239      2      37 scrit::ui::AddHandler::handle@43-80@.\app\addhandler.cpp

...

       1      1      8      1       0 blank_deleter@5-5@.\test\test.hpp
--------------------------------------------------------------
105 file analyzed.
==============================================================
NLOC    Avg.NLOC AvgCCN Avg.ttoken  function_cnt    file
--------------------------------------------------------------
     63     26    4.0       238         2     .\app\addhandler.cpp

...

      2      1    1.0         8         1     .\test\test.hpp

=================================================================
!!!! Warnings (CCN > 15 or arguments > 100 or length > 1000) !!!!
================================================
  NLOC    CCN   token  PARAM  length  location  
------------------------------------------------
      36     27    862      3      36 tpunit::TestFixture::__fp_equal@436-472@.\dep\tpunitpp\tpunit++.hpp
==========================================================================================
Total nloc  Avg.nloc  Avg CCN  Avg token  Fun Cnt  Warning cnt   Fun Rt   nloc Rt  
------------------------------------------------------------------------------------------
      8487         3     1.14      22.74     1684            1      0.00    0.01

I tried it on a couple other machines (windows and linux) with no success. It also didn't work on 3.4.3.

terryyin commented 8 years ago

Yeah, now the reason is because you run it with -m, not by the installed lizard script.

Let me make the -m work as well. Will let you know. On 19 Jan 2016 12:40, "U.G. Wilson" notifications@github.com wrote:

Sorry, still doesn't work.

Install shows correct version.

C:\workspace\machina>python -m pip install lizard Collecting lizard Using cached lizard-1.9.18.tar.gz Installing collected packages: lizard Running setup.py install for lizard Successfully installed lizard-1.9.18

Run on directory still doesn't work.

C:\workspace\machina>python -m lizard

NLOC CCN token PARAM length location


0 file analyzed.

NLOC Avg.NLOC AvgCCN Avg.ttoken function_cnt file

!!!! Warnings (CCN > 15 or arguments > 100 or length > 1000) !!!!

NLOC CCN token PARAM length location

Total nloc Avg.nloc Avg CCN Avg token Fun Cnt Warning cnt Fun Rt nloc Rt

     0         1     0.00       0.00        1            0      0.00    0.00

Run on source file still does.

C:\workspace\machina>python -m lizard ex.py

NLOC CCN token PARAM length location


1 file analyzed.

NLOC Avg.NLOC AvgCCN Avg.ttoken function_cnt file

 84      0    0.0         0         0     ex.py

!!!! Warnings (CCN > 15 or arguments > 100 or length > 1000) !!!!

NLOC CCN token PARAM length location

Total nloc Avg.nloc Avg CCN Avg token Fun Cnt Warning cnt Fun Rt nloc Rt

    84         1     0.00       0.00        1            0      0.00    0.00

It does work on C++ source directories.

C:\workspace\scrit>python -m lizard

NLOC CCN token PARAM length location

  28      4    239      2      37 scrit::ui::AddHandler::handle@43-80@.\app\addhandler.cpp

...

   1      1      8      1       0 blank_deleter@5-5@.\test\test.hpp

105 file analyzed.

NLOC Avg.NLOC AvgCCN Avg.ttoken function_cnt file

 63     26    4.0       238         2     .\app\addhandler.cpp

...

  2      1    1.0         8         1     .\test\test.hpp

!!!! Warnings (CCN > 15 or arguments > 100 or length > 1000) !!!!

NLOC CCN token PARAM length location

  36     27    862      3      36 tpunit::TestFixture::__fp_equal@436-472@.\dep\tpunitpp\tpunit++.hpp

Total nloc Avg.nloc Avg CCN Avg token Fun Cnt Warning cnt Fun Rt nloc Rt

  8487         3     1.14      22.74     1684            1      0.00    0.01

I tried it on a couple other machines (windows and linux) with no success. It also didn't work on 3.4.3.

— Reply to this email directly or view it on GitHub https://github.com/terryyin/lizard/issues/83#issuecomment-172728872.

c0yote commented 8 years ago

So should this way work?

C:\workspace\machina>lizard
================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
--------------------------------------------------------------
0 file analyzed.
==============================================================
NLOC    Avg.NLOC AvgCCN Avg.ttoken  function_cnt    file
--------------------------------------------------------------

=================================================================
!!!! Warnings (CCN > 15 or arguments > 100 or length > 1000) !!!!
================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
==========================================================================================
Total nloc  Avg.nloc  Avg CCN  Avg token  Fun Cnt  Warning cnt   Fun Rt   nloc Rt
------------------------------------------------------------------------------------------
         0         1     0.00       0.00        1            0      0.00    0.00

C:\workspace\machina>lizard ex.py
================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
--------------------------------------------------------------
1 file analyzed.
==============================================================
NLOC    Avg.NLOC AvgCCN Avg.ttoken  function_cnt    file
--------------------------------------------------------------
     84      0    0.0         0         0     ex.py

=================================================================
!!!! Warnings (CCN > 15 or arguments > 100 or length > 1000) !!!!
================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
==========================================================================================
Total nloc  Avg.nloc  Avg CCN  Avg token  Fun Cnt  Warning cnt   Fun Rt   nloc Rt
------------------------------------------------------------------------------------------
        84         1     0.00       0.00        1            0      0.00    0.00
terryyin commented 8 years ago

Hmmm. Can you let me see the output of lizard -h? On 19 Jan 2016 13:47, "U.G. Wilson" notifications@github.com wrote:

So should this way work?

C:\workspace\machina>lizard

NLOC CCN token PARAM length location


0 file analyzed.

NLOC Avg.NLOC AvgCCN Avg.ttoken function_cnt file

!!!! Warnings (CCN > 15 or arguments > 100 or length > 1000) !!!!

NLOC CCN token PARAM length location

Total nloc Avg.nloc Avg CCN Avg token Fun Cnt Warning cnt Fun Rt nloc Rt

     0         1     0.00       0.00        1            0      0.00    0.00

C:\workspace\machina>lizard ex.py

NLOC CCN token PARAM length location


1 file analyzed.

NLOC Avg.NLOC AvgCCN Avg.ttoken function_cnt file

 84      0    0.0         0         0     ex.py

!!!! Warnings (CCN > 15 or arguments > 100 or length > 1000) !!!!

NLOC CCN token PARAM length location

Total nloc Avg.nloc Avg CCN Avg token Fun Cnt Warning cnt Fun Rt nloc Rt

    84         1     0.00       0.00        1            0      0.00    0.00

— Reply to this email directly or view it on GitHub https://github.com/terryyin/lizard/issues/83#issuecomment-172735838.

c0yote commented 8 years ago
C:\workspace\machina>lizard -h
usage: lizard [options] [PATH or FILE] [PATH] ...

lizard is a simple code complexity analyzer without caring about the C/C++
header files or Java imports. For more information visit http://www.lizard.ws

positional arguments:
  paths                 list of the filename/paths.

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -l LANGUAGES, --languages LANGUAGES
                        List the programming languages you want to analyze. if
                        left empty, it'll search for all languages it knows.
                        `lizard -l cpp -l java`searches for C++ and Java code.
                        The available languages are: cpp
  -V, --verbose         Output in verbose mode (long function name)
  -C CCN, --CCN CCN     Threshold for cyclomatic complexity number warning.
                        The default value is 15. Functions with CCN bigger
                        than it will generate warning
  -L LENGTH, --length LENGTH
                        Threshold for maximum function length warning. The
                        default value is 1000. Functions length bigger than it
                        will generate warning
  -a ARGUMENTS, --arguments ARGUMENTS
                        Limit for number of parameters
  -w, --warnings_only   Show warnings only, using clang/gcc's warning format
                        for printing warnings.
                        http://clang.llvm.org/docs/UsersManual.html#cmdoption-
                        fdiagnostics-format
  -i NUMBER, --ignore_warnings NUMBER
                        If the number of warnings is equal or less than the
                        number, the tool will exit normally, otherwise it will
                        generate error. Useful in makefile for legacy code.
  -x EXCLUDE, --exclude EXCLUDE
                        Exclude files that match this pattern. * matches
                        everything, ? matches any single character,
                        "./folder/*" exclude everything in the folder
                        recursively. Multiple patterns can be specified. Don't
                        forget to add "" around the pattern.
  -t WORKING_THREADS, --working_threads WORKING_THREADS
                        number of working threads. The default value is 1.
                        Using a bigger number can fully utilize the CPU and
                        often faster.
  -X, --xml             Generate XML in cppncss style instead of the tabular
                        output. Useful to generate report in Jenkins server
  -H, --html            Output HTML report
  -m, --modified        Calculate modified cyclomatic complexity number
  -E EXTENSIONS, --extension EXTENSIONS
                        User the extensions. The available extensions are:
                        -Ecpre: it will ignore code in the #else branch.
                        -Ewordcount: count word frequencies and generate tag
                        cloud. -Eoutside: include the global code as one
                        function. -EIgnoreAssert: to ignore all code in assert
  -s SORTING, --sort SORTING
                        Sort the warning with field. The field can be nloc,
                        cyclomatic_complexity, token_count, parameter_count,
                        etc. Or an customized file.
  -W WHITELIST, --whitelist WHITELIST
                        The path and file name to the whitelist file. It's
                        './whitelizard.txt' by default. Find more information
                        in README.
terryyin commented 8 years ago

Hmm, strange. The listed languages only has cpp. Let me investigate...

What about lizard --version? On 19 Jan 2016 13:50, "U.G. Wilson" notifications@github.com wrote:

C:\workspace\machina>lizard -h usage: lizard [options] [PATH or FILE] [PATH] ...

lizard is a simple code complexity analyzer without caring about the C/C++ header files or Java imports. For more information visit http://www.lizard.ws

positional arguments: paths list of the filename/paths.

optional arguments: -h, --help show this help message and exit --version show program's version number and exit -l LANGUAGES, --languages LANGUAGES List the programming languages you want to analyze. if left empty, it'll search for all languages it knows. lizard -l cpp -l javasearches for C++ and Java code. The available languages are: cpp -V, --verbose Output in verbose mode (long function name) -C CCN, --CCN CCN Threshold for cyclomatic complexity number warning. The default value is 15. Functions with CCN bigger than it will generate warning -L LENGTH, --length LENGTH Threshold for maximum function length warning. The default value is 1000. Functions length bigger than it will generate warning -a ARGUMENTS, --arguments ARGUMENTS Limit for number of parameters -w, --warnings_only Show warnings only, using clang/gcc's warning format for printing warnings. http://clang.llvm.org/docs/UsersManual.html#cmdoption- fdiagnostics-format -i NUMBER, --ignore_warnings NUMBER If the number of warnings is equal or less than the number, the tool will exit normally, otherwise it will generate error. Useful in makefile for legacy code. -x EXCLUDE, --exclude EXCLUDE Exclude files that match this pattern. * matches everything, ? matches any single character, "./folder/*" exclude everything in the folder recursively. Multiple patterns can be specified. Don't forget to add "" around the pattern. -t WORKING_THREADS, --working_threads WORKING_THREADS number of working threads. The default value is 1. Using a bigger number can fully utilize the CPU and often faster. -X, --xml Generate XML in cppncss style instead of the tabular output. Useful to generate report in Jenkins server -H, --html Output HTML report -m, --modified Calculate modified cyclomatic complexity number -E EXTENSIONS, --extension EXTENSIONS User the extensions. The available extensions are: -Ecpre: it will ignore code in the #else branch. -Ewordcount: count word frequencies and generate tag cloud. -Eoutside: include the global code as one function. -EIgnoreAssert: to ignore all code in assert -s SORTING, --sort SORTING Sort the warning with field. The field can be nloc, cyclomatic_complexity, token_count, parameter_count, etc. Or an customized file. -W WHITELIST, --whitelist WHITELIST The path and file name to the whitelist file. It's './whitelizard.txt' by default. Find more information in README.

— Reply to this email directly or view it on GitHub https://github.com/terryyin/lizard/issues/83#issuecomment-172736080.

terryyin commented 8 years ago

@c0yote can you confirm the lizard --version? (without -m)

c0yote commented 8 years ago
C:\workspace\machina>lizard --version
1.9.18
terryyin commented 8 years ago

@c0yote the problem is fixed now:-)

c0yote commented 8 years ago

It is indeed, sir. Thanks for your effort! Great software!

terryyin commented 8 years ago

have you tried lizard -EWordCount ? lot of fun:-)

c0yote commented 8 years ago

Second thing I did, lol. It's pretty spiffy. Was pleasantly surprised with the words that came out, haha.

terryyin commented 8 years ago

Thanks for the issue:-) Let's close it now.