ludeeus / action-shellcheck

GitHub action for ShellCheck.
MIT License
292 stars 69 forks source link

Action appears to be check all files rather than just shell scripts #14

Closed dre2004 closed 4 years ago

dre2004 commented 4 years ago

I've had some issues running this action, it's picking up all sorts of files (javascript, go, etc).

I know I can set an exclude to exclude all the directories that don't contain shell scripts in my project but that seems a little counter intuitive.

Run ludeeus/action-shellcheck@master
/usr/bin/docker run --name d346b9a69434f4483696d184d929557435_bdb93b --label 3888d3 --workdir /github/workspace --rm -e INPUT_IGNORE -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/gogs/gogs":"/github/workspace" 3888d3:46b9a69434f4483696d184d929557435

In ./internal/route/user/profile.go line 1:
// Copyright 2015 The Gogs Authors. All rights reserved.
^-- SC1127: Was this intended as a comment? Use # in sh.
^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang.

In ./internal/route/user/profile.go line 2:
// Use of this source code is governed by a MIT-style
^-- SC1127: Was this intended as a comment? Use # in sh.

In ./internal/route/user/profile.go line 3:
// license that can be found in the LICENSE file.
^-- SC1127: Was this intended as a comment? Use # in sh.

Having a look at the script that runs in the container, I think the problem appears to be here.

readarray -d '' tmp < <(find . "${excludes[@]}" -type f ! -name '*.*' -perm /111  -print0)
for file in "${tmp[@]}"; do
    head -n1 "$file" | grep -Eqs "^#! */[^ ]*/[abkz]*sh" || continue
    filepaths+=("$file")
done
ludeeus commented 4 years ago

Can you paste the first line of the file ./internal/route/user/profile.go ?

dre2004 commented 4 years ago

It happens with all go files, I think that was just one of the examples.

I have forked the gogs repository (https://github.com/dre2004/gogs) and trying to use shellcheck for the shell scripts in that repository.

// Copyright 2015 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package user

import (
    "strings"

    "github.com/unknwon/paginater"

    "gogs.io/gogs/internal/conf"
    "gogs.io/gogs/internal/context"
    "gogs.io/gogs/internal/db"
    "gogs.io/gogs/internal/route/repo"
    "gogs.io/gogs/internal/tool"
)
ludeeus commented 4 years ago

Try running master now

dre2004 commented 4 years ago

That fixed it ! keep up the good work!