GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ophiosdev/pre-commit-psscriptanalyzer: pre-commit hooks for linting and formatting PowerShell code via PSScriptAnalyzer

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.envrc
.envrc
 
 
.gitignore
.gitignore
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
.pre-commit-hooks.yaml
.pre-commit-hooks.yaml
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
PSScriptAnalyzer-wrapper.ps1
PSScriptAnalyzer-wrapper.ps1
 
 
README.md
README.md
 
 
devbox.json
devbox.json
 
 
devbox.lock
devbox.lock
 
 
pre-commit-run.sh
pre-commit-run.sh
 
 

Repository files navigation

pre-commit-psscriptanalyzer

Pre-Commit

This project provides pre-commit hooks to lint and format PowerShell code, using the PSScriptAnalyzer static code checker.

Setup

To activate the hooks, add the following lines to the repos list in the project's .pre-commit-config.yaml file:

---
repos:
  - repo: https://github.com/ophiosdev/pre-commit-psscriptanalyzer.git
    rev: v2.0.0
    hooks:
      # Check PowerShell code
      - id: psscriptanalyzer-check
      # Format PowerShell code
      - id: psscriptanalyzer-format

These hooks require PowerShell to run.

Alternatively use this to run the hooks with Docker (so no dependency on PowerShell is needed):

---
repos:
  - repo: https://github.com/ophiosdev/pre-commit-psscriptanalyzer.git
    rev: v2.0.0
    hooks:
      # Check PowerShell code
      - id: psscriptanalyzer-check-docker
      # Format PowerShell code
      - id: psscriptanalyzer-format-docker

Supported hooks

psscriptanalyzer-check

The psscriptanalyzer-check hook performs checks on PowerShell code, based on selected best practice rules. It supports the following options from the PSScriptAnalyzer function Invoke-ScriptAnalyzer:

  • -CustomRulePath
  • -ExcludeRule
  • -Fix
  • -IncludeDefaultRules
  • -IncludeRule
  • -IncludeSuppressed
  • -RecurseCustomRulePath
  • -SaveDscDependency
  • -Settings
  • -Severity

The psscriptanalyzer-check-docker hook supports the same options.

To pass multiple values like to the -ExcludeRule parameter, create a single string where the values are separated by a , (comma) without any whitespaces

---
repos:
  - repo: https://github.com/ophiosdev/pre-commit-psscriptanalyzer.git
    rev: v2.0.0
    hooks:
      # Check PowerShell code
      - id: psscriptanalyzer-check
        args:
          - '-ExcludeRule'
          - 'PSAvoidUsingConvertToSecureStringWithPlainText,PSAvoidUsingWriteHost'

psscriptanalyzer-format

The psscriptanalyzer-format formats PowerShell code to a canonical format. It supports the following options from the PSScriptAnalyzer function Invoke-Formatter :

  • -Range
  • -Settings

The psscriptanalyzer-format-docker hook supports the same options.

Copyright and license

© 2023 Mohamed El Morabity © 2024 Ophios GmbH

Licensed under the GNU GPL, version 3.0 or later.

About

pre-commit hooks for linting and formatting PowerShell code via PSScriptAnalyzer

Topics

powershellpre-commitpre-commit-cipre-commit-configpre-commit-hookpre-commit-hooks

Resources

Readme
GPL-3.0 license
Activity
Custom properties

Stars

1 star

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.