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.84k stars 249 forks source link

can't run new version 1.14.0 #225

Closed mosesliao closed 6 years ago

mosesliao commented 6 years ago

Hi @terryyin, I can't run the new version of lizard. This is what I get

$ pip3 install lizard
Collecting lizard
  Using cached lizard-1.14.0-py2.py3-none-any.whl
Installing collected packages: lizard
Successfully installed lizard-1.14.0
SPIS-TECH-MB84:infinity-ios pmlg673f$ lizard --version
Traceback (most recent call last):
  File "/usr/local/bin/lizard", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/lizard.py", line 969, in main
    options = parse_args(argv or sys.argv)
  File "/usr/local/lib/python3.6/site-packages/lizard.py", line 913, in parse_args
    parser = extend_parser(arg_parser(argv[0]))
  File "/usr/local/lib/python3.6/site-packages/lizard.py", line 98, in arg_parser
    parser.add_argument('--version', action='version', version=version)
NameError: name 'version' is not defined

Please look into it. Thanks

mosesliao commented 6 years ago

@terryyin still error

$ lizard --html serenity
Traceback (most recent call last):
  File "/usr/local/bin/lizard", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/lizard.py", line 985, in main
    warning_count = printer(result, options, schema)
  File "/usr/local/lib/python3.6/site-packages/lizard_ext/htmloutput.py", line 38, in html_output
    output = env.get_template('template.html').render(
  File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 830, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 804, in _load_template
    template = self.loader.load(self, name, globals)
  File "/usr/local/lib/python3.6/site-packages/jinja2/loaders.py", line 113, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/usr/local/lib/python3.6/site-packages/jinja2/loaders.py", line 187, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: template.html
terryyin commented 6 years ago

OK. Should work now.

On 20 Mar 2018, at 9:03 AM, Liao Gangzheng Moses notifications@github.com wrote:

@terryyin https://github.com/terryyin still error

$ lizard --html serenity Traceback (most recent call last): File "/usr/local/bin/lizard", line 11, in sys.exit(main()) File "/usr/local/lib/python3.6/site-packages/lizard.py", line 985, in main warning_count = printer(result, options, schema) File "/usr/local/lib/python3.6/site-packages/lizard_ext/htmloutput.py", line 38, in html_output output = env.get_template('template.html').render( File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 830, in get_template return self._load_template(name, self.make_globals(globals)) File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 804, in _load_template template = self.loader.load(self, name, globals) File "/usr/local/lib/python3.6/site-packages/jinja2/loaders.py", line 113, in load source, filename, uptodate = self.get_source(environment, name) File "/usr/local/lib/python3.6/site-packages/jinja2/loaders.py", line 187, in get_source raise TemplateNotFound(template) jinja2.exceptions.TemplateNotFound: template.html — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terryyin/lizard/issues/225#issuecomment-374437058, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwJYh-2dqBAZZsS8FoXc41i8xnQZb7Hks5tgFVxgaJpZM4SrfH7.

mosesliao commented 6 years ago

dude, not solved yet

$ lizard --version
1.14.8
$ lizard --html -l swift serenity
Traceback (most recent call last):
  File "/usr/local/bin/lizard", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/lizard.py", line 985, in main
    warning_count = printer(result, options, schema)
  File "/usr/local/lib/python3.6/site-packages/lizard_ext/htmloutput.py", line 40, in html_output
    output = env.get_template('template.html').render(
  File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 830, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 804, in _load_template
    template = self.loader.load(self, name, globals)
  File "/usr/local/lib/python3.6/site-packages/jinja2/loaders.py", line 113, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/usr/local/lib/python3.6/site-packages/jinja2/loaders.py", line 187, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: template.html
terryyin commented 6 years ago

eh, this time it's truly strange. I tested it with Mac and Windows and both worked.

I added a new change which will try sys.exec_prefix if it failed to find the template in sys.prefix. Please try if this fixes it. Otherwise I need to put the template.html in code.

mosesliao commented 6 years ago

I would suggest you put template.html in code

You can try running this modified example of Dockerfile I use for fastlane-plugin-lizard for circleci

FROM circleci/ruby

USER root
RUN apt-get -y update && apt-get -y upgrade
RUN apt-get install -y python3-pip
RUN apt-get install -y apt-utils
RUN pip3 install lizard --upgrade
RUN pip3 install jinja2 --upgrade
RUN lizard --version
RUN lizard --xml ~
RUN lizard --html ~

This is what I get in the end

 ---> 3945254385b3
Step 8/10 : RUN lizard --version
 ---> Running in b3e487a9bf6c
1.14.9
Removing intermediate container b3e487a9bf6c
 ---> 54db5248fe2e
Step 9/10 : RUN lizard --xml ~
 ---> Running in 30a737baca5e
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="https://raw.githubusercontent.com/terryyin/lizard/master/lizard.xsl"?>
<cppncss>
    <measure type="Function">
        <labels>
            <label>Nr.</label>
            <label>NCSS</label>
            <label>CCN</label>
        </labels>
    </measure>
    <measure type="File">
        <labels>
            <label>Nr.</label>
            <label>NCSS</label>
            <label>CCN</label>
            <label>Functions</label>
        </labels>
        <sum label="NCSS" value="0"/>
        <sum label="CCN" value="0"/>
        <sum label="Functions" value="0"/>
    </measure>
</cppncss>

Removing intermediate container 30a737baca5e
 ---> f8dd5d502ac6
Step 10/10 : RUN lizard --html ~
 ---> Running in 97e9496b4ba9
Traceback (most recent call last):
  File "/usr/local/bin/lizard", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/lizard.py", line 985, in main
    warning_count = printer(result, options, schema)
  File "/usr/local/lib/python3.5/dist-packages/lizard_ext/htmloutput.py", line 42, in html_output
    output = env.get_template('template.html').render(
  File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 830, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 804, in _load_template
    template = self.loader.load(self, name, globals)
  File "/usr/local/lib/python3.5/dist-packages/jinja2/loaders.py", line 113, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/usr/local/lib/python3.5/dist-packages/jinja2/loaders.py", line 187, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: template.html
The command '/bin/sh -c lizard --html ~' returned a non-zero code: 1

Obviously xml work but html doesn't

The circleci ruby docker image uses debian OS as the base

terryyin commented 6 years ago

Thanks for the docker file! It’s now really fixed:-)

On 21 Mar 2018, at 1:55 PM, Liao Gangzheng Moses notifications@github.com wrote:

I would suggest you put template.html in code

You can try running this modified example of Dockerfile I use for fastlane-plugin-lizard for circleci

FROM circleci/ruby

USER root RUN apt-get -y update && apt-get -y upgrade RUN apt-get install -y python3-pip RUN apt-get install -y apt-utils RUN pip3 install lizard --upgrade RUN pip3 install jinja2 --upgrade RUN lizard --version RUN lizard --xml ~ RUN lizard --html ~ This is what I get in the end

---> 3945254385b3 Step 8/10 : RUN lizard --version ---> Running in b3e487a9bf6c 1.14.9 Removing intermediate container b3e487a9bf6c ---> 54db5248fe2e Step 9/10 : RUN lizard --xml ~ ---> Running in 30a737baca5e <?xml version="1.0" ?> <?xml-stylesheet type="text/xsl" href="https://raw.githubusercontent.com/terryyin/lizard/master/lizard.xsl"?>

Removing intermediate container 30a737baca5e ---> f8dd5d502ac6 Step 10/10 : RUN lizard --html ~ ---> Running in 97e9496b4ba9 Traceback (most recent call last): File "/usr/local/bin/lizard", line 11, in sys.exit(main()) File "/usr/local/lib/python3.5/dist-packages/lizard.py", line 985, in main warning_count = printer(result, options, schema) File "/usr/local/lib/python3.5/dist-packages/lizard_ext/htmloutput.py", line 42, in html_output output = env.get_template('template.html').render( File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 830, in get_template return self._load_template(name, self.make_globals(globals)) File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 804, in _load_template template = self.loader.load(self, name, globals) File "/usr/local/lib/python3.5/dist-packages/jinja2/loaders.py", line 113, in load source, filename, uptodate = self.get_source(environment, name) File "/usr/local/lib/python3.5/dist-packages/jinja2/loaders.py", line 187, in get_source raise TemplateNotFound(template) jinja2.exceptions.TemplateNotFound: template.html The command '/bin/sh -c lizard --html ~' returned a non-zero code: 1 Obviously xml work but html doesn't

The circleci ruby docker image uses debian OS as the base

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terryyin/lizard/issues/225#issuecomment-374840075, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwJYmyln_MISFgk-cnfza0GBRDT2N4aks5tges3gaJpZM4SrfH7.

mosesliao commented 6 years ago

You are welcomed.

But can I suggest that you tighten the CI/CD process? maybe when I have the time I can help you add some unit tests so that we don't need to make so many mistakes just to get something working launched. Better than me just writing a readme to tag the plugin to lizard

terryyin commented 6 years ago

That would be great. There has been so many mistakes is mostly because I took the html output pull request in a haste, which until now still doesn’t have any real test. That’s somewhere a lot of improvement is needed.

Also, I will add a smoke test for releases.

On 22 Mar 2018, at 10:28 AM, Liao Gangzheng Moses notifications@github.com wrote:

You are welcomed.

But can I suggest that you tighten the CI/CD process? maybe when I have the time I can help you add some unit tests so that we don't need to make so many mistakes just to get something launched. Better than me just writing a readme to tag the plugin to lizard

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.