Closed GadgetSteve closed 8 years ago
Added correction to the url in setup.py
Hi Steve, you probably noticed that this is fairly old code. If I remember correctly this was done in 2010 and I moved it to Github about two years ago. I do not think that I ever used the command line of this module other than for debugging. On first look your code looks good but I have some trouble verifying your pull request. Honestly I do not use metrics at the moment and I can not even say if it still makes sense. Do you by any chance have test cases that verify the bugfix you made? Best Mark
Hi Mark,
The last fix is just updating the URL to point to the correct location in github, clicking on the link on pypi takes you to completely the wrong location.
The previous, longer one - I have tested manually several times by simply running:
`metrics -r .' on the command line in a directory that has sub-directories, e.g.:
F:\toolbuild\metrics>metrics --format=csv -r . options: {'recurse_dir': '.', 'verbose': 0, 'quiet': False, 'lib_name': '', 'inc lude_metrics_str': 'sloc:SLOCMetric,mccabe:McCabeMetric', 'output_format_str': ' csv', 'in_file_list': None} args: [] Recurse . sloc mccabe sloc SLOCMetric mccabe McCabeMetric Metrics Summary: Files Language SLOC Comment McCabe
1 XML 93 20 0
1 JavaScript+Lasso 1446 47 169
1 JavaScript+Genshi Text 6 7 0
3 Java 43 66 1
28 Python 1464 588 273 1 JavaScript 1 1 0 6 C 14 3 0 3 C++ 1114 236 108 6 Text only 0 0 0 1 INI 4 0 0
51 Total 4185 968 551 filename,mccabe,ratio_comment_to_code,language,comments,sloc .\metrics.egg-info\SOURCES.txt,0,0.0,Text only,0,0 .\tests\code_samples\foo_upper_case.C,0,0.33,C++,1,3 .\build\lib\metrics\processargs.py,18,0.35,Python,47,134 .\tests\code_samples\js1.js,169,0.03,JavaScript+Lasso,47,1446 .\metrics\processargs.py,18,0.35,Python,47,134 .\tests\test_file_javascript.py,0,0.13,Python,3,24 .\metrics\sloc.py,9,0.43,Python,22,51 .\build\lib\metrics\sloc.py,9,0.43,Python,22,51 .\build\lib\metrics\metricbase.py,0,0.56,Python,5,9 .\tests\code_samples\nsMaiInterfaceHyperlinkImpl.cpp,1,1.77,C++,39,22 .\tests\test_file_python.py,0,0.12,Python,3,25 .\tests\test_output_xml.py,0,0.16,Python,3,19 .\tests\code_samples\emacs_mode.c,0,1.0,C,2,0 .\metrics\mccabe.py,1,0.43,Python,12,28 .\tests\code_samples\uses_cpp_headers.h,0,0.0,C,0,2 .\tests\code_samples\uses_cpp_stdlib_headers.h,0,0.0,C,0,2 .\tests\code_samples\python_sample.py,125,0.49,Python,193,391 .\tests\code_samples\nsAccessibleWrap.cpp,107,0.18,C++,196,1089 .\metrics.egg-info\entry_points.txt,0,0.0,Text only,0,0 .\setup.cfg,0,0.0,INI,0,4 .\tests\code_samples\js3.js,0,1.0,JavaScript,1,1 .\build\lib\metrics\mccabe.py,1,0.43,Python,12,28 .\build\lib\metrics\compute.py,8,0.57,Python,21,37 .\tests\support.py,0,1.4,Python,7,5 .\sample.txt,0,0.0,Text only,0,0 .\metrics.egg-info\dependency_links.txt,0,0.0,Text only,0,0 .\metrics\compute.py,8,0.57,Python,21,37 .\pom.xml,0,0.22,XML,20,93 .\build\lib\metrics\outputformatCSV.py,2,0.38,Python,5,13 .\tests\code_samples\py1.py,0,2.0,Python,10,5 .\build\lib\metricsinit.py,0,7.0,Python,7,1 .\metrics.egg-info\requires.txt,0,0.0,Text only,0,0 .\metrics\outputformatXML.py,11,0.22,Python,6,27 .\metricsinit.py,0,7.0,Python,7,1 .\metrics\metrics.py,25,0.38,Python,55,146 .\build\lib\metrics\outputformatXML.py,11,0.22,Python,6,27 .\tests\test_output_csv.py,0,0.16,Python,3,19 .\metrics.egg-info\top_level.txt,0,0.0,Text only,0,0 .\build\lib\metrics\metrics.py,25,0.38,Python,55,146 .\tests\code_samples\java1.java,1,0.22,Java,6,27 .\tests\test_file_cpp.py,0,0.12,Python,3,25 .\tests\code_samples\uses_cpp_keywords.h,0,0.0,C,0,3 .\tests\test_lexer.py,0,0.0,Python,0,16 .\metrics\metricbase.py,0,0.56,Python,5,9 .\tests\code_samples\java2.java,0,1.0,Java,2,0 .\src\main\java\org\aogaeru\InitJython.java,0,3.63,Java,58,16 .\tests\code_samples\js2.js,0,1.17,JavaScript+Genshi Text,7,6 .\tests\code_samples\uses_no_cpp.h,0,0.0,C,0,4 .\setup.py,0,0.07,Python,3,43 .\tests\code_samples\foo.c,0,0.33,C,1,3 .\metrics\outputformatCSV.py,2,0.38,Python,5,13
I took a second look at your pull request and I have to make an addition to what I said earlier. print statements are not a good idea here! print might be tolerable in the main / CLI part but in the library part which is used by other programs and libraries you definitely do not want to print out to the console. This might not be relevant for how you use the code. So probably the easiest is you maintain your changes as a fork.
Fair Enough.
Other than on very small projects it is necessary to create a list of files to process prior to using the package, this can be inconvenient and/or confusing for some users so this adds a -r dir_name option to allow recursive parsing. As verbose in the original code does very little made use of this flag to display file names as processing continues.
Also fixed two exceptions that contained errors in print formatting - the first was using a name that did not exist mm and the second at least some python interpreters were evaluating the % before the + resulting in a problem as the display elements were spread over 2 sub-strings. The .sjb in on the version string was just so that I could distinguish versions.