{"id":20801889,"url":"https://github.com/philips-software/python_guardrails","last_synced_at":"2025-06-12T22:37:30.079Z","repository":{"id":47482763,"uuid":"256236914","full_name":"philips-software/python_guardrails","owner":"philips-software","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-15T18:44:04.000Z","size":216,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-18T12:34:23.250Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philips-software.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-16T14:21:43.000Z","updated_at":"2021-08-30T05:34:33.000Z","dependencies_parsed_at":"2022-08-27T10:40:49.369Z","dependency_job_id":null,"html_url":"https://github.com/philips-software/python_guardrails","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fpython_guardrails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fpython_guardrails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fpython_guardrails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fpython_guardrails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philips-software","download_url":"https://codeload.github.com/philips-software/python_guardrails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243147272,"owners_count":20243745,"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":[],"created_at":"2024-11-17T18:24:58.171Z","updated_at":"2025-03-12T02:47:12.940Z","avatar_url":"https://github.com/philips-software.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Python application](https://github.com/philips-software/python_guardrails/workflows/Python%20application/badge.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/gh/philips-software/python_guardrails/branch/master/graph/badge.svg)](https://codecov.io/gh/philips-software/python_guardrails)\n\nGuardrails for python projects\n=============================\n\nWhat is the project intended to solve?\n-------------------------------------\nProject will help to consolidate clean coding practices at the developers desk by a single call which consolidates\n (linting, copy paste detection, Dead code, Test coverage, Cyclomatic complexity, Mutation testing)\n\nTechnology stack\n---------------\n1. Python with few python packages\n2. jscpd `https://www.npmjs.com/package/jscpd`\n\nDependencies\n------------\n```\nPython 3.8\nNodeJS 10\nJSCPD 3.2.1\n```\n\n[packages]\n\n```\npip\n\nmutmut\n\npytest\n\nLizard\n\nvulture\n\ncodecov\n\npytest-cov\n\npylint\n\nglob2\n```\n\n\nInstall, Usage \u0026 Configuration\n--------------------\n1. Install the tool using `pip install guardrails`\n2. Install jscpd `https://www.npmjs.com/package/jscpd`\n3. update the `guardrail.ini` file, content of which is listed below\n``` \n[folder]\n# Fields under folder config are mandatory, if not provided, \n# will be considering the path of this ini file\n\n# Comma seperated source folders if more than one directory\nsource_folder = .\\EagleVision\\eaglevision\n# Comma seperated test folders if more than one directory\ntest_folder = .\\EagleVision\\test\npytest_root = .\\EagleVision\\test\nreport_folder = ..\\opensource\\python_guardrails\\guardrails_report\njscpd_root = .\\EagleVision\n\n[python]\npython = python\n# path to the .pylintrc file if specific linting or leave empty after =\npylint_rc_file = .\\EagleVision\\.pylintrc\n\n[coverage]\n# path to the .coveragerc file if specific cverage config or leave empty after =\ncoverage_rc_file =\n\n[gates]\n# gate values are absolute integers\n# duplicate to ken count\njscpd_duplicate_token = 20\n# Jscpd allowed % duplication\njscpd_allowed_duplication = 7\n# coverage gating %\ncoverage_percentage = 85\n# Allowed mutats %\nallowed_mutants_percentage = 20\n# cyclomatic complexity allowed value\ncyclomatic_complexity_allowed = 10\n# minimum deadcode confidence\nmin_deadcode_confidence = 50\n\n[ignore]\n# pylint ignore to be added in the pylintrc file\n# Add files or directories matching the regex patterns to the blacklist. The\n# regex matches against base names, not paths.\n# Ignore all .py files under the 3rdparty subdirectory.\n\n# ignore-patterns=**/3rdparty/**/*.py\n\n# Comma seperated folders if more than one directory or leave empty after = for example cyclomatic_complexity_exclude = \"*guardrails.py\", \"*guardrail_globals.py\"\n# more details @https://pypi.org/project/lizard/1.17.7/\ncyclomatic_complexity_exclude =\n# Comma seperated source folders if more than one directory or leave empty after = for example jscpd_ignore = \"**/*.min.js,**/*.map\"\n# More details @ https://www.npmjs.com/package/jscpd#ignored-blocks\njscpd_ignore = \n# Comma seperated source folders if more than one directory or leave empty after = for example If you want to ignore a whole file or directory, use the --exclude parameter (e.g., --exclude *settings.py,docs/\n# more details @ https://pypi.org/project/vulture/#description\ndead_code_ignore =\n\n# whitelist deadcode (relative path to whitelist.py) [.\\path\\whitelist.py] or leave it empty after = \ndead_code_whitelist = \n\n[others]\n# Comma seperated language if more than one, for CPD reporting\nprogramming_language = python\n\n[options]\n# option can be either true or false\nlinting=false\ncpd=false\ncoverage=false\nmutation=false\ndeadcode=false\ncyclomatic_complexity=false\n```\n4. To call from commandline\n```\npython -m guardrails --p path\\to\\guardrail.ini #ini file created for respective project\n```\nSample execution report\n----------------------\n```\n#####Guardrails for python programs#####\nPassed linting gate\n====================================\nExecution Time: 111.103ms\nPassed JSCPD gating\n====================================\n================================================= test session starts =================================================\nplatform win32 -- Python 3.7.3, pytest-4.6.9, py-1.8.0, pluggy-0.12.0\nrootdir: C:\\public_repo\\python_guardrails\nplugins: allure-pytest-2.8.5, cov-2.7.1, html-2.0.1, metadata-1.8.0, pylint-0.14.1\ncollected 1 item\n\ntest\\test_sample.py .                                                                                            [100%]\n\n----------- coverage: platform win32, python 3.7.3-final-0 -----------\nCoverage HTML written to dir Sample_proj_cov\n\n\n============================================== 1 passed in 0.19 seconds ===============================================\nPassed testing using pytest\n====================================\nName                 Stmts   Miss  Cover\n----------------------------------------\nsource\\__init__.py       0      0   100%\nsource\\sample.py         3      0   100%\n----------------------------------------\nTOTAL                    3      0   100%\nPassed test coverage gating\n====================================\n\n- Mutation testing starting -\n\nThese are the steps:\n1. A full test suite run will be made to make sure we\n   can run the tests successfully and we know how long\n   it takes (to detect infinite loops for example)\n2. Mutants will be generated and checked\n\nResults are stored in .mutmut-cache.\nPrint found mutants with `mutmut results`.\n\nLegend for output:\n🎉 Killed mutants.   The goal is for everything to end up in this bucket.\n⏰ Timeout.          Test suite took 10 times as long as the baseline so were killed.\n🤔 Suspicious.       Tests took a long time, but not long enough to be fatal.\n🙁 Survived.         This means your tests needs to be expanded.\n\nmutmut cache is out of date, clearing it...\n1. Running tests without mutations\n⠇ Running... Done\n\n2. Checking mutants\n⠹ 2/2  🎉 2  ⏰ 0  🤔 0  🙁 0\nPassed mutation testing gate\n====================================\nPassed Dead code gating\n====================================\nPassed Cyclomatic complexity gating\n====================================\n```\nReport \u0026 Log\n-----------\n- Report will be collected at the `report_folder` folder mentioned in the guardrail.ini file\n- Log file will be generated inside the guardrails package installation with name `guardrails.log`\n\nContact / Getting help\n----------------------\n[MAINTAINERS.md](MAINTAINERS.md)\n\nLicense\n--------\n[License.md](License.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilips-software%2Fpython_guardrails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilips-software%2Fpython_guardrails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilips-software%2Fpython_guardrails/lists"}