Skip to content

aNereds/magento2-coding-standard

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magento2 Code Sniffer Github Action

​ This repository's aim is to provide open sourced GitHub action to develop better Magento 2 extensions. ​

Main Functionalities

Executes on Repository events Like Pull-request or Merge e.t.c

img.png

Installation

In your GitHub repository add the below as <root>.github/workflows/coding-standard.yml

name: M2 Coding Standard
on:
  push:
  pull_request:
    branches:
      - "*"
jobs:
  static:
    name: Magento 2 Coding Standard
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: M2 code standard
        id: magento
        uses: aNereds/magento2-coding-standard@master
        with:
          fileExtensions: "php,phtml,xml"
          onlyErrors: "no"
          sourceReport: "yes"
      - name: Get the output time
        run: echo "Action Output, ${{ steps.magento.outputs.time }}"

Configuration

Setting up file Extensions to include in report

By default, PHP_CodeSniffer will check any file it finds with a .inc, .php, .js or .css extension, although not all standards will actually check all these file types. Sometimes, this means that PHP_CodeSniffer is not checking enough of your files. Sometimes, the opposite is true. To specify file extensions can be added separated by coma to override default values

....
        with:
          fileExtensions: "php,phtml,xml" - ### Here can be specified file extensions for validation
          onlyErrors: "yes"
          sourceReport: "yes"
....

Disabling Warning in Report

If you don't want warnings included in the output, specify the -n command line argument. By following coding-standard.yml file adjustments.

....
        with:
          fileExtensions: "php,phtml,xml"
          onlyErrors: "yes" - ### This flag should be set to yes
          sourceReport: "yes"
....

Enabling Source Report

By default, PHP_CodeSniffer will print a complete list of all errors and warnings it finds. This list can become quite long, especially when checking a large number of files at once. To print a summary report that only shows the number of errors and warnings for each file, use the sourceReport: "yes" set to yes.

....
        with:
          fileExtensions: "php,phtml,xml"
          onlyErrors: "no" 
          sourceReport: "yes" - ### This flag should be set to yes
....