Skip to content

Commit

Permalink
Merge pull request #1 from synergy-au/feature/minor-fixes
Browse files Browse the repository at this point in the history
Minor code refactoring and bug fix on the URL in the messages.
  • Loading branch information
Clint-Chester authored Apr 1, 2021
2 parents 9be6f68 + b44fd4c commit ac7e47c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Run PMD Analyser
uses: synergy-au/pmd-analyser-action@v1
with:
pmd-version: '6.28.0'
pmd-version: '6.33.0'
file-path: './src'
rules-path: './pmd-ruleset.xml'
error-rules: 'AvoidDirectAccessTriggerMap,AvoidDmlStatementsInLoops,AvoidHardcodingId'
Expand Down Expand Up @@ -56,7 +56,7 @@ Path to the sources to analyse. This can be a file name, a directory, or a jar o
The version of PMD you would like to run.

- required: true
- default: '6.27.0'
- default: '6.33.0'

### rules-path

Expand Down
23 changes: 18 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,30 @@ inputs:
pmd-version:
description: 'The version of PMD you would like to run.'
required: false
default: '6.28.0'
default: '6.33.0'
rules-path:
description: 'The ruleset file you want to use. PMD uses xml configuration files, called rulesets, which specify which rules to execute on your sources. You can also run a single rule by referencing it using its category and name (more details here). For example, you can check for unnecessary modifiers on Java sources with -R category/java/codestyle.xml/UnnecessaryModifier.'
required: true
runs:
using: "composite"
steps:
- run: |
- id: branches
run: |
if [ ${{ github.event_name }} == 'pull_request' ]; then
${{ github.action_path }}/pmd-analyser.sh ${{ inputs.pmd-version }} ${{ inputs.file-path }} ${{ inputs.rules-path }} ${{ inputs.analyse-all-code }} ${{ github.base_ref }} ${{ github.head_ref }} ${{ inputs.error-rules }}
echo "::set-output name=target::${{ github.base_ref }}"
echo "::set-output name=source::${{ github.head_ref }}"
else
${{ github.action_path }}/pmd-analyser.sh ${{ inputs.pmd-version }} ${{ inputs.file-path }} ${{ inputs.rules-path }} ${{ inputs.analyse-all-code }} ${{ github.event.repository.default_branch }} ${{ github.ref }} ${{ inputs.error-rules }}
echo "::set-output name=target::${{ github.event.repository.default_branch }}"
echo "::set-output name=source::${{ github.ref }}"
fi
shell: bash
shell: bash
- run: ${{ github.action_path }}/pmd-analyser.sh
shell: bash
env:
PMD_VERSION: ${{ inputs.pmd-version }}
FILE_PATH: ${{ inputs.file-path }}
RULES_PATH: ${{ inputs.rules-path }}
ANALYSE_ALL_CODE: ${{ inputs.analyse-all-code }}
TARGET_BRANCH: ${{ steps.branches.outputs.target }}
SOURCE_BRANCH: ${{ steps.branches.outputs.source }}
ERROR_RULES: ${{ inputs.error-rules }}
9 changes: 1 addition & 8 deletions pmd-analyser.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# shellcheck shell=sh

PMD_VERSION=$1
FILE_PATH=$2
RULES_PATH=$3
ANALYSE_ALL_CODE=$4
TARGET_BRANCH=$5
SOURCE_BRANCH=$6
ERROR_RULES=$7
ERROR_COUNT=0

# Download PMD
Expand All @@ -25,7 +18,7 @@ fi
while read -r file; do
FILENAME="$(echo "$file" | jq --raw-output '.filename | ltrimstr("${{ github.workspace }}/")')"
while read -r violation; do
MESSAGE="$(echo "$violation" | jq --raw-output '" \(.ruleset) - \(.rule): \(.description). This applies from line \(.beginline) to \(.endline) and from column \(.begincolumn) to \(.endcolumn). For more information on this rule visit \(.externalInfoUrl)."')"
MESSAGE="$(echo "$violation" | jq --raw-output '" \(.ruleset) - \(.rule): \(.description). This applies from line \(.beginline) to \(.endline) and from column \(.begincolumn) to \(.endcolumn). For more information on this rule visit \(.externalInfoUrl)"')"
LINE="$(echo "$violation" | jq --raw-output '.beginline')"
COLUMN="$(echo "$violation" | jq --raw-output '.begincolumn')"
RULE="$(echo "$violation" | jq --raw-output '.rule')"
Expand Down

0 comments on commit ac7e47c

Please sign in to comment.