Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support related locations #55

Merged
merged 7 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ inputs:
runs:
using: 'composite'
steps:
- uses: reviewdog/action-setup@v1
with:
reviewdog_version: v0.18.1
- run: $GITHUB_ACTION_PATH/script.sh
shell: bash
env:
REVIEWDOG_VERSION: 'v0.17.5'
INPUT_GITHUB_TOKEN: '${{ inputs.github_token }}'
INPUT_WORKDIR: '${{ inputs.workdir }}'
INPUT_LEVEL: '${{ inputs.level }}'
Expand Down
4 changes: 0 additions & 4 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@
PATH="${TEMP_PATH}:$PATH"
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1
echo '::endgroup::'

echo '::group:: Installing staticcheck ... https://staticcheck.io'
curl -sfL "https://github.com/dominikh/go-tools/releases/latest/download/staticcheck_linux_amd64.tar.gz" | tar -xvz -C "${TEMP_PATH}" --strip-components=1
echo '::endgroup::'


echo '::group:: Running staticcheck with reviewdog 🐶 ...'
staticcheck ${INPUT_STATICCHECK_FLAGS} -f=json ${INPUT_TARGET:-.} \

Check warning on line 16 in script.sh

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./script.sh:16:13:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check warning on line 16 in script.sh

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./script.sh:16:48:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check failure on line 16 in script.sh

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck (suggestion)] reported by reviewdog 🐶 Raw Output: script.sh:16:-staticcheck ${INPUT_STATICCHECK_FLAGS} -f=json ${INPUT_TARGET:-.} \ script.sh:16:+staticcheck "${INPUT_STATICCHECK_FLAGS}" -f=json "${INPUT_TARGET:-.}" \
| jq -f "${GITHUB_ACTION_PATH}/to-rdjsonl.jq" -c | \
reviewdog \
-f="rdjsonl" \
Expand All @@ -26,7 +22,7 @@
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}

Check warning on line 25 in script.sh

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./script.sh:25:7:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check failure on line 25 in script.sh

View workflow job for this annotation

GitHub Actions / runner / shellcheck

[shellcheck (suggestion)] reported by reviewdog 🐶 Raw Output: script.sh:25:- ${INPUT_REVIEWDOG_FLAGS} script.sh:25:+ "${INPUT_REVIEWDOG_FLAGS}"

exit_code=$?
echo '::endgroup::'
Expand Down
8 changes: 7 additions & 1 deletion testdata/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@
)

const (
First byte = 1

Check failure on line 10 in testdata/testdata.go

View workflow job for this annotation

GitHub Actions / runner / staticcheck (github-pr-review)

[staticcheck] reported by reviewdog 🐶 only the first constant in this group has an explicit type Raw Output: {"source":{"name":"staticcheck","url":"https://staticcheck.io"},"message":"only the first constant in this group has an explicit type","code":{"value":"SA9004","url":"https://staticcheck.io/docs/checks#SA9004"},"location":{"path":"/home/runner/work/action-staticcheck/action-staticcheck/testdata/testdata.go","range":{"start":{"line":10,"column":2},"end":{"line":10,"column":17}}},"related_locations":[],"severity":"ERROR"}
Second = 2
)

func unused() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <U1000> reported by reviewdog 🐶
func unused is unused

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <U1000> reported by reviewdog 🐶
func unused is unused

regexp.Compile(".+")

nonNilVar := []int{}

if errors.New("abcd") == errors.New("abcd") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <SA9003> reported by reviewdog 🐶
empty branch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <SA9003> reported by reviewdog 🐶
empty branch

// Test SA4000
}

regexp.Compile(".\\")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <S1007> reported by reviewdog 🐶
should use raw string (...) with regexp.Compile to avoid having to escape twice

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <SA1000> reported by reviewdog 🐶
error parsing regexp: trailing backslash at end of expression: ``

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <S1007> reported by reviewdog 🐶
should use raw string (...) with regexp.Compile to avoid having to escape twice

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <SA1000> reported by reviewdog 🐶
error parsing regexp: trailing backslash at end of expression: ``


s := []string{}
if s != nil {
if s != nil { // test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <S1031> reported by reviewdog 🐶
unnecessary nil check around range

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <SA4031> reported by reviewdog 🐶
this nil check is always true


this is the value of s

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <SA4031> reported by reviewdog 🐶
this nil check is always true


this is the value of s

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <SA4031> reported by reviewdog 🐶
this nil check is always true


this is the value of s

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <SA4031> reported by reviewdog 🐶
this nil check is always true


this is the value of s

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <S1031> reported by reviewdog 🐶
unnecessary nil check around range

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <SA4031> reported by reviewdog 🐶
this nil check is always true


this is the value of s

for _, x := range s {
fmt.Println(x)
}
}

if nonNilVar != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <SA4031> reported by reviewdog 🐶
this nil check is always true


this is the value of nonNilVar

nonNilVar := []int{}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <SA4031> reported by reviewdog 🐶
this nil check is always true


this is the value of nonNilVar

nonNilVar := []int{}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [staticcheck] <SA4031> reported by reviewdog 🐶
this nil check is always true


this is the value of nonNilVar

nonNilVar := []int{}

fmt.Println(nonNilVar)
}
}
20 changes: 20 additions & 0 deletions to-rdjsonl.jq
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,28 @@
start: {
line: .location.line,
column: .location.column
},
end: {
line: .end.line,
column: .end.column
}
}
},
related_locations: (.related // {}) | map({
message: .message,
location: {
path: .location.file,
range: {
start: {
line: .location.line,
column: .location.column
},
end: {
line: .end.line,
column: .end.column
}
}
}
}),
severity: ((.severity|ascii_upcase|select(match("ERROR|WARNING|INFO")))//null)
}
Loading