{"id":18544037,"url":"https://github.com/themimitoof/black-gl-code-quality","last_synced_at":"2025-04-09T19:30:39.421Z","repository":{"id":211315949,"uuid":"728825428","full_name":"Themimitoof/black-gl-code-quality","owner":"Themimitoof","description":"A simple wrapper to convert Black outputs to codeclimate report format for GitLab-CI","archived":false,"fork":false,"pushed_at":"2024-09-13T08:47:53.000Z","size":21,"stargazers_count":1,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-13T15:22:12.974Z","etag":null,"topics":["black","code-quality","codeclimate","gitlab","gitlab-ci","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/black-gl-code-quality/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Themimitoof.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-07T19:22:37.000Z","updated_at":"2024-09-13T08:47:39.000Z","dependencies_parsed_at":"2024-09-13T19:34:10.222Z","dependency_job_id":null,"html_url":"https://github.com/Themimitoof/black-gl-code-quality","commit_stats":null,"previous_names":["themimitoof/black-gl-code-quality"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Themimitoof%2Fblack-gl-code-quality","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Themimitoof%2Fblack-gl-code-quality/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Themimitoof%2Fblack-gl-code-quality/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Themimitoof%2Fblack-gl-code-quality/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Themimitoof","download_url":"https://codeload.github.com/Themimitoof/black-gl-code-quality/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223407838,"owners_count":17140562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["black","code-quality","codeclimate","gitlab","gitlab-ci","python"],"created_at":"2024-11-06T20:15:11.282Z","updated_at":"2024-11-06T20:15:11.840Z","avatar_url":"https://github.com/Themimitoof.png","language":"Python","readme":"# Black GitLab Code Quality\n\nThis project aim to convert [Black](https://github.com/psf/black) report to\n[CodeClimate](https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md)\nformat that can be ingest by GitLab.\n\n```\n→ poetry run black-gl-cq src/black_gl_code_quality | jq\n[\n  {\n    \"type\": \"issue\",\n    \"description\": \"Black would reformat\",\n    \"location\": {\n      \"lines\": {\n        \"begin\": 1,\n        \"end\": 1\n      },\n      \"path\": \"src/black_gl_code_quality/__main__.py\"\n    },\n    \"severity\": \"major\"\n  },\n  {\n    \"type\": \"issue\",\n    \"description\": \"Black would reformat\",\n    \"location\": {\n      \"lines\": {\n        \"begin\": 1,\n        \"end\": 1\n      },\n      \"path\": \"src/black_gl_code_quality/error.py\"\n    },\n    \"severity\": \"major\"\n  }\n]\n```\n\n## Motivation\n\nFor security concerns, Docker-in-Docker has been disabled in all GitLab runners that I\nhave access/manage. Because the Code Quality template shipped with GitLab instances use\nCodeClimate CLI that requires a Docker environment, we can't use it and an alternative\nsolution was required to obtain Black errors in our Code Quality reports.\n\n\n## How to install\n\nSimply run the following command:\n\n```\npip install black-gl-code-quality\n```\n\nIf you use Poetry, you can add it to your dev-dependencies:\n\n```\npoetry add --group dev black-gl-code-quality\n```\n\n## Usage\n\nThere is two ways to use this tool:\n\n - by piping Black\n - by calling `black-gl-code-quality` (or by it's alias `black-gl-cq`) directly\n\n\n### Piping with Black\n\nPiping with Black requires to forward  `stderr` to `stdout`. You can use the following\ncommand in the `.gitlab-ci.yml`:\n\n```\nblack --check src/ 2\u003e\u00261 | black-gl-cq \u003e black-code-quality-report.json\n```\n\nHere's an example for a GitLab-CI job:\n\n```yaml\nlint:black:\n  stage: test\n  script:\n    - source .venv/bin/activate\n    - black --check src/ 2\u003e\u00261 | black-gl-cq \u003e black-code-quality-report.json\n  artifacts:\n    when: always\n    reports:\n      codequality: black-code-quality-report.json\n```\n\n### Calling `black-gl-code-quality` directly\n\nCalling `black-gl-code-quality` (or it's alias `black-gl-cq`) execute Black with the\n`--check` argument. It forwards all arguments you pass if you need to configure Black\nvia the CLI.\n\nSpecifying source folders is **MANDATORY**.\n\nHere's an example for a GitLab-CI job:\n\n```yaml\nlint:black:\n  stage: test\n  script:\n    - source .venv/bin/activate\n    - black-gl-cq src/ \u003e black-code-quality-report.json\n  artifacts:\n    when: always\n    reports:\n      codequality: black-code-quality-report.json\n```\n\nAdmit we want to skip string normalization:\n\n```yaml\nlint:black:\n  stage: test\n  script:\n    - source .venv/bin/activate\n    - black-gl-cq -S src/ \u003e black-code-quality-report.json\n  artifacts:\n    when: always\n    reports:\n      codequality: black-code-quality-report.json\n```\n\n### Change severity\n\nBy default, all errors have the severity `major`. Depending how you consider Black issues\nimportant, you can change the severity for all errors returned by the report by using\none of the following [values](https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#issues)\nwith the `BLACK_GL_SEVERITY` environment variable: `info`, `minor`, `major`, `critical`, `blocker`.\n\nHere's an example for a GitLab-CI job:\n\n```yaml\nlint:black:\n  stage: test\n  variables:\n    BLACK_GL_SEVERITY: minor\n  script:\n    - source .venv/bin/activate\n    - black-gl-cq src/ \u003e black-code-quality-report.json\n  artifacts:\n    when: always\n    reports:\n      codequality: black-code-quality-report.json\n```\n\n### Debugging\n\nIt is possible to pass the `-v` argument to `black-gl-cq` to stream Black's output to stderr.\n\nHere's an example:\n\n```\n$ poetry run black-gl-cq -v src \u003e black-code-quality-report.json\nIdentified `/home/themimitoof/repos/black-gl-code-quality` as project root containing a .git directory.\nSources to be formatted: \"src\"\n/home/themimitoof/repos/black-gl-code-quality/src/black_gl_code_quality/__init__.py wasn't modified on disk since last run.\n/home/themimitoof/repos/black-gl-code-quality/src/black_gl_code_quality/parser.py wasn't modified on disk since last run.\n/home/themimitoof/repos/black-gl-code-quality/src/black_gl_code_quality/error.py already well formatted, good job.\n/home/themimitoof/repos/black-gl-code-quality/src/black_gl_code_quality/__main__.py already well formatted, good job.\n\nAll done! ✨ 🍰 ✨\n4 files would be left unchanged.\n```\n\n## Contributions\n\nIn case you have a suggestion or want a new feature, feel free to open a\n[discussion](https://github.com/Themimitoof/black-gl-code-quality/discussions).\n\nIf you found a bug, you can [open an issue](https://github.com/Themimitoof/black-gl-code-quality/issues).\n\nIn order to maintain an overall good code quality, this project use the following tools:\n\n - [Black](https://github.com/psf/black)\n - [Isort](https://github.com/PyCQA/isort)\n - [Flake8](https://flake8.pycqa.org/en/latest/)\n\nLinting and formatting tools are configured to match the [current default rules of Black](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html).\n\nPlease ensure to run these tools before commiting and submiting a Pull request. In case one of\nthese mentionned tools report an error, the CI will automatically fail.\n\nIn case you are able to fix by yourself a bug, enhance the code or implement a new\nfeature, feel free to send a [Pull request](https://github.com/Themimitoof/black-gl-code-quality/pulls).\n\n## License\n\nThis project is released under the [BSD-3 Clause](LICENSE). Feel free to use,\ncontribute, fork and do what you want with it. Please keep all licenses, copyright\nnotices and mentions in case you use, re-use, steal, fork code from this repository.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthemimitoof%2Fblack-gl-code-quality","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthemimitoof%2Fblack-gl-code-quality","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthemimitoof%2Fblack-gl-code-quality/lists"}