wemake-services / wemake-python-styleguide

The strictest and most opinionated python linter ever!
https://wemake-python-styleguide.rtfd.io
MIT License
2.51k stars 378 forks source link

Build codeclimate engine to be used with their platform #634

Open sobolevn opened 5 years ago

sobolevn commented 5 years ago

https://codeclimate.com/blog/build-your-own-codeclimate-engine/

Then we can fill their form to suggest the engine: https://codeclimate.com/dev_form/

sobolevn commented 5 years ago

Here are the specs: https://github.com/codeclimate/spec

sobolevn commented 5 years ago

Related #638

thepabloaguilar commented 3 years ago

As WPS is a flake8 plugin this project here (https://pypi.org/project/flake8-codeclimate/) doesn't solve this issue?

sobolevn commented 3 years ago

Looks like it does!

sobolevn commented 3 years ago

@thepabloaguilar do you ming creating a PR to add this to our docs?

thepabloaguilar commented 3 years ago

Nop, I'll open ASAP

thepabloaguilar commented 3 years ago

Ok, I've checked and it'lll not work for this case! It just handles the basic cases, also it seems a bit unmaintained. This scared me:

def error_category(error):
    try:
        return error_classes[error.code]["category"]
    except KeyError:
        try:
            return error_classes[error.code][:2]["category"]
        except KeyError:
            try:
                return error_classes[error.code][:1]["category"]
            except KeyError:
                return category_bug

I saw your discussion https://github.com/bennylope/flake8-codeclimate/issues/5 about extending, but I think isn't possible to do that! With that in mind let's use WPS formatter and adding an option like --wemake-codeclimate to be provided by the user, so we change the formatter based on that option! WDYT?

Also, I can try to create a separated plugin by my own to handle all the projects code (that's can be easy if every project will have a file with all the codes and its severity)!

sobolevn commented 3 years ago

Also, I can try to create a separated plugin by my own to handle all the projects code (that's can be easy if every project will have a file with all the codes and its severity)!

This might be really useful!

thepabloaguilar commented 3 years ago

I've started with WPS, I scraped its documentation and exported a JSON file. My idea is to build an "index" with all the codes, many scrapers one for each plugin! I think it's worth since people doesn't change the documentation structure a lot (maybe never).

If you want to see the initial format:

[
  {"error_code": "WPS300", "error_name": "LocalFolderImportViolation", "description": "Found local folder import"},
  {"error_code": "WPS301", "error_name": "DottedRawImportViolation", "description": "Found dotted raw import: {0}"},
  {"error_code": "WPS302", "error_name": "UnicodeStringViolation", "description": "Found unicode string prefix: {0}"},
  {"error_code": "WPS303", "error_name": "UnderscoredNumberViolation", "description": "Found underscored number: {0}"},
  {"error_code": "WPS304", "error_name": "PartialFloatViolation", "description": "Found partial float: {0}"},
  {"error_code": "WPS305", "error_name": "FormattedStringViolation", "description": "Found `f` string"},
  {"error_code": "WPS100", "error_name": "WrongModuleNameViolation", "description": "Found wrong module name"},
  {"error_code": "WPS101", "error_name": "WrongModuleMagicNameViolation", "description": "Found wrong module magic name"}
  ...
]

Btw, WPS has 234 checks!

sobolevn commented 3 years ago

This might help you as well https://flake8.codes/

mschoettle commented 1 year ago

There is also this package: https://github.com/awelzel/flake8-gl-codeclimate

(the GitLab code quality report is a subset of the code climate spec)