{"id":13599270,"url":"https://github.com/MathieuBuisson/PSCodeHealth","last_synced_at":"2025-04-10T12:32:03.436Z","repository":{"id":88662444,"uuid":"80985174","full_name":"MathieuBuisson/PSCodeHealth","owner":"MathieuBuisson","description":"PowerShell module gathering PowerShell code quality and maintainability metrics","archived":false,"fork":false,"pushed_at":"2020-09-29T08:59:28.000Z","size":835,"stargazers_count":126,"open_issues_count":14,"forks_count":16,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-27T08:02:47.452Z","etag":null,"topics":["code-analysis","code-quality","powershell"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MathieuBuisson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-02-05T10:19:06.000Z","updated_at":"2025-02-18T19:15:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"df7245e9-d7af-43b9-9ca8-842ca0e5dcaa","html_url":"https://github.com/MathieuBuisson/PSCodeHealth","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/MathieuBuisson%2FPSCodeHealth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathieuBuisson%2FPSCodeHealth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathieuBuisson%2FPSCodeHealth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MathieuBuisson%2FPSCodeHealth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MathieuBuisson","download_url":"https://codeload.github.com/MathieuBuisson/PSCodeHealth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217131,"owners_count":21066633,"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":["code-analysis","code-quality","powershell"],"created_at":"2024-08-01T17:01:01.577Z","updated_at":"2025-04-10T12:32:01.223Z","avatar_url":"https://github.com/MathieuBuisson.png","language":"PowerShell","readme":"# PSCodeHealth  \u0026nbsp; \u0026nbsp; \u0026nbsp;\u003cimg src= \"https://github.com/MathieuBuisson/PSCodeHealth/raw/master/PSCodeHealth/Assets/PSCodeHealthLogo.png\" alt=\"PSCodeHealth Logo\" width=\"70\" align=\"center\"/\u003e\n  \n  \n[![Build status](https://ci.appveyor.com/api/projects/status/7lns5hedci8hfjm3/branch/master?svg=true)](https://ci.appveyor.com/project/MathieuBuisson/pscodehealth/branch/master) [![Coverage Status](https://coveralls.io/repos/github/MathieuBuisson/PSCodeHealth/badge.svg?branch=master)](https://coveralls.io/github/MathieuBuisson/PSCodeHealth?branch=master) [![Documentation Status](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](http://pscodehealth.readthedocs.io/en/latest/?badge=latest) [![PS Gallery](https://img.shields.io/badge/install-PS%20Gallery-blue.svg)](https://www.powershellgallery.com/packages/PSCodeHealth/)  \n\n## Overview  \n\n\u003e \"**If you can't measure it, you can't improve it.**\"  \nPeter Drucker\n\nPSCodeHealth allows you to measure the quality and maintainability of your PowerShell code, based on a variety of metrics related to :  \n  - Code length  \n  - Code complexity  \n  - Code smells, styling issues and violations of best practices  \n  - Tests and test coverage  \n  - Comment-based help  \n\nIt can allow you to ensure that your code is compliant with metrics goals (quality gates). You can use the default (built-in) compliance rules, and you can also customize some (or all) compliance rules to fit your goals.  \n\nThese features can be leveraged from within your PowerShell release pipeline.  \n\nPSCodeHealth can also generate a highly visual HTML report so that you can interpret the results at a glance, and easily share them.  \nFor example, here is what the **Summary** tab looks like :  \n![HTML report - Summary section](https://raw.githubusercontent.com/MathieuBuisson/PSCodeHealth/master/Examples/SummarySectionScreenshot.png \"HTML report - Summary section\")  \n\u0026nbsp;  \n\nAnd here is an example of what the **Style \u0026 Best Practices** tab looks like :  \n![HTML report - Style \u0026 Best Practices section](https://raw.githubusercontent.com/MathieuBuisson/PSCodeHealth/master/Examples/BestPracticesSectionScreenshot.png \"HTML report - Style \u0026 Best Practices section\")  \n\n## Requirements  \n\nBefore using PSCodeHealth, you need :  \n  - PowerShell 5.x  \n  - The **[Pester](https://github.com/pester/Pester)** PowerShell module (version 3.4.0 or later)  \n  - The **[PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer)** PowerShell module  \n  - Internet access when opening the HTML report (to download some CSS and Javascript for Bootstrap, jQuery and Chart.js)  \n\n## Installation\n\n### From the PowerShell Gallery\n\nThe easiest and preferred way to install PSCodeHealth is via the [PowerShell Gallery](https://www.powershellgallery.com/). For more information, see the [PowerShell Gallery Getting Started](https://msdn.microsoft.com/en-us/powershell/gallery/psgallery/psgallery_gettingstarted) page.  \n\nRun the following command to install PSCodeHealth and its 2 dependencies ([Pester](https://github.com/pester/Pester) and\n[PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer)) :  \n\n```powershell\nInstall-Module -Name PSCodeHealth -Repository PSGallery\n```\n\n### From Chocolatey\n\nIf you prefer to manage PSCodeHealth as a Windows package, you can use Chocolatey. If you don't have Chocolatey, you can install it from the [Chocolately Install](https://chocolatey.org/install) page. With Chocolatey installed, execute the following command to install:\n\n```powershell\nchoco install pscodehealth\n```\n\nNote: the PSCodeHealth Chocolatey package is provided and supported by the community.\n\n### From Github\n\nAs an alternative, you can clone this repository to a location on your system and copy the `PSCodeHealth` subfolder into :\n`C:\\Program Files\\WindowsPowerShell\\Modules\\`.  \n\n## Getting Started  \n\nTo evaluate the code quality of a single script, simply use the **`Invoke-PSCodeHealth`** command.  \nSpecify the relative or full path of the script file via the `Path` parameter and specify the location of the tests via the `TestsPath` parameter, like so :  \n\n```powershell\nPS C:\\\u003e Invoke-PSCodeHealth -Path '.\\coveralls\\Coveralls.ps1' -TestsPath '.\\coveralls'\n\nFiles    Functions      LOC (Average)  Findings       Findings       Complexity    Test Coverage\n                                       (Total)        (Average)      (Average)                  \n-----    ---------      -------------  -------------- -------------- ------------- -------------\n1        9              22.33          0              0              2             39.58 %      \n\n```  \n\nTo evaluate the code quality of all the PowerShell code in a directory, specify the relative or full path of the directory via the `Path` parameter, like so :  \n\n```powershell\nPS C:\\\u003e Invoke-PSCodeHealth -Path '.\\coveralls' -TestsPath '.\\coveralls'\n\nFiles    Functions      LOC (Average)  Findings       Findings       Complexity    Test Coverage\n                                       (Total)        (Average)      (Average)                  \n-----    ---------      -------------  -------------- -------------- ------------- -------------\n3        9              22.33          0              0              2             38.78 %      \n\n```  \n\nTo view the per-function information, access the `FunctionHealthRecords` property of the output of **`Invoke-PSCodeHealth`** :\n\n```powershell\nC:\\\u003e $HealthReport = Invoke-PSCodeHealth -Path '.\\coveralls' -TestsPath '.\\coveralls'\nC:\\\u003e $HealthReport.FunctionHealthRecords\n\nFunction Name               Lines of Code   Complexity     Contains Help  Test Coverage  ScriptAnalyzer\n                                                                                            Findings   \n-------------               -------------   ----------     -------------  -------------  --------------\nAdd-CoverageInfo            14              1              False          0 %                  0       \nMerge-CoverageResult        21              1              False          0 %                  0       \nGet-CoverageArray           30              5              False          94.44 %              0       \nFormat-FileCoverage         24              2              False          100 %                0       \nGet-CommandsForFile         16              1              False          100 %                0       \nGet-GitInfo                 23              2              False          0 %                  0       \nFormat-Coverage             39              3              False          0 %                  0       \nPublish-Coverage            18              1              False          0 %                  0       \nGet-CoveragePercentage      16              2              False          100 %                0       \n\n```\n\nTo output the PSCodeHealth report as an HTML file, use the `HtmlReportPath` parameter to specify the full path of the HTML file :\n\n```powershell\nC:\\\u003e Invoke-PSCodeHealth -Path '.\\coveralls' -TestsPath '.\\coveralls' -HtmlReportPath \"$env:USERPROFILE\\Desktop\\Report.html\"\n\n```\n  \nThe above command will not output anything to the PowerShell pipeline, unless you add the `PassThru` parameter.  \n\nWant to know more ? Head to the full documentation :  \n\u003chttp://pscodehealth.readthedocs.io/en/latest/\u003e  \n\n## Contributing to PSCodeHealth\n\nYou are welcome to contribute to this project. There are many ways you can contribute :\n\n1. Submit [issues](https://github.com/MathieuBuisson/PSCodeHealth/issues). In this case, please use the project's [issue template](https://github.com/MathieuBuisson/PSCodeHealth/blob/master/.github/ISSUE_TEMPLATE.md).  \n2. Submit a fix for an issue.  \n3. Submit a feature request.  \n4. Submit test cases.  \n5. Tell others about the project.  \n6. Tell the developers how much you appreciate the project !  \n\nFor more information on how to contribute to PSCodeHealth, please refer to the [contributing guidelines](https://github.com/MathieuBuisson/PSCodeHealth/blob/master/.github/CONTRIBUTING.md) document.  \n","funding_links":[],"categories":["PowerShell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMathieuBuisson%2FPSCodeHealth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMathieuBuisson%2FPSCodeHealth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMathieuBuisson%2FPSCodeHealth/lists"}