lordmauve / flake8-html

Generate HTML reports of flake8 violations
Other
51 stars 17 forks source link

Enable recursive folder making #12

Closed Eskumu closed 4 years ago

Eskumu commented 6 years ago

Description

I ran flake8 and wanted it to create html report in report/style folder. If reports folder was not present the html was not generated and script exited with error. The same happened on windows and docker image.

What I Did

The command I ran

flake8 django-judocup/ --format=html --htmldir=reports/style

output on Windows:

(venv) C:\Users\pro\Documents\Django\judocup>flake8 django-judocup/ --format=html --htmldir=reports/style
Traceback (most recent call last):
  File "C:\Users\pro\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\pro\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\pro\Documents\Django\judocup\venv\Scripts\flake8.exe\__main__.py", line 9, in <module>
  File "c:\users\pro\documents\django\judocup\venv\lib\site-packages\flake8\main\cli.py", line 16, in main
    app.run(argv)
  File "c:\users\pro\documents\django\judocup\venv\lib\site-packages\flake8\main\application.py", line 396, in run
    self._run(argv)
  File "c:\users\pro\documents\django\judocup\venv\lib\site-packages\flake8\main\application.py", line 383, in _run
    self.initialize(argv)
  File "c:\users\pro\documents\django\judocup\venv\lib\site-packages\flake8\main\application.py", line 368, in initialize
    self.make_formatter()
  File "c:\users\pro\documents\django\judocup\venv\lib\site-packages\flake8\main\application.py", line 267, in make_formatter
    self.formatter = formatter_class(self.options)
  File "c:\users\pro\documents\django\judocup\venv\lib\site-packages\flake8\plugins\manager.py", line 139, in execute
    return self.plugin(*args, **kwargs)  # pylint: disable=not-callable
  File "c:\users\pro\documents\django\judocup\venv\lib\site-packages\flake8\formatting\base.py", line 41, in __init__
    self.after_init()
  File "c:\users\pro\documents\django\judocup\venv\lib\site-packages\flake8_html\plugin.py", line 81, in after_init
    os.mkdir(self.outdir)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'reports/style'

Output on the docker image

Traceback (most recent call last):
  File "/usr/local/bin/flake8", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main
    app.run(argv)
  File "/usr/local/lib/python3.6/site-packages/flake8/main/application.py", line 396, in run
    self._run(argv)
  File "/usr/local/lib/python3.6/site-packages/flake8/main/application.py", line 383, in _run
    self.initialize(argv)
  File "/usr/local/lib/python3.6/site-packages/flake8/main/application.py", line 368, in initialize
    self.make_formatter()
  File "/usr/local/lib/python3.6/site-packages/flake8/main/application.py", line 267, in make_formatter
    self.formatter = formatter_class(self.options)
  File "/usr/local/lib/python3.6/site-packages/flake8/plugins/manager.py", line 139, in execute
    return self.plugin(*args, **kwargs)  # pylint: disable=not-callable
  File "/usr/local/lib/python3.6/site-packages/flake8/formatting/base.py", line 41, in __init__
    self.after_init()
  File "/usr/local/lib/python3.6/site-packages/flake8_html/plugin.py", line 81, in after_init
    os.mkdir(self.outdir)
FileNotFoundError: [Errno 2] No such file or directory: 'reports/style'
lordmauve commented 4 years ago

As mentioned in #13 I don't think this is a good behaviour for a tool like this. If you misspell something high up the path, like

myporject/src/python/linters/flake8-html

then you create all those directories by accident, and cleaning them up is annoying. Better to only create the leaf directory, so that a typo can be fixed by a simple mv.