wemake-python-styleguide icon indicating copy to clipboard operation
wemake-python-styleguide copied to clipboard

Build codeclimate engine to be used with their platform

Open sobolevn opened this issue 5 years ago • 11 comments

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 avatar Jul 08 '19 17:07 sobolevn

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

sobolevn avatar Jul 08 '19 17:07 sobolevn

Related #638

sobolevn avatar Jul 09 '19 17:07 sobolevn

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

thepabloaguilar avatar Oct 07 '21 06:10 thepabloaguilar

Looks like it does!

sobolevn avatar Oct 07 '21 07:10 sobolevn

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

sobolevn avatar Oct 07 '21 07:10 sobolevn

Nop, I'll open ASAP

thepabloaguilar avatar Oct 07 '21 08:10 thepabloaguilar

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)!

thepabloaguilar avatar Oct 08 '21 04:10 thepabloaguilar

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!

sobolevn avatar Oct 08 '21 08:10 sobolevn

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!

thepabloaguilar avatar Oct 09 '21 08:10 thepabloaguilar

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

sobolevn avatar Oct 09 '21 08:10 sobolevn

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)

mschoettle avatar Dec 04 '22 23:12 mschoettle