Skip to content

Commit

Permalink
Merge pull request #306 from rhysd/revert-290-stronger-external-checks
Browse files Browse the repository at this point in the history
Revert "Stronger external checks"
  • Loading branch information
rhysd authored Jun 10, 2023
2 parents 251d10b + b40f49a commit 2d99b21
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 100 deletions.
6 changes: 2 additions & 4 deletions linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,7 @@ func (l *Linter) check(
if err == nil {
rules = append(rules, r)
} else {
l.log("Error in rule \"shellcheck\":", err)
return nil, err
l.log("Rule \"shellcheck\" was disabled:", err)
}
} else {
l.log("Rule \"shellcheck\" was disabled since shellcheck command name was empty")
Expand All @@ -520,8 +519,7 @@ func (l *Linter) check(
if err == nil {
rules = append(rules, r)
} else {
l.log("Error in rule \"pyflakes\":", err)
return nil, err
l.log("Rule \"pyflakes\" was disabled:", err)
}
} else {
l.log("Rule \"pyflakes\" was disabled since pyflakes command name was empty")
Expand Down
96 changes: 0 additions & 96 deletions linter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,102 +16,6 @@ import (
"golang.org/x/sys/execabs"
)

func TestLinterShellcheckCommandNotFound(t *testing.T) {
dir := filepath.Join("testdata", "ok")

es, err := os.ReadDir(dir)
if err != nil {
panic(err)
}

fs := make([]string, 0, len(es))
for _, e := range es {
if e.IsDir() {
continue
}
n := e.Name()
if strings.HasSuffix(n, ".yaml") || strings.HasSuffix(n, ".yml") {
fs = append(fs, filepath.Join(dir, n))
}
}

proj := &Project{root: dir}

shellcheck := "i_am_not_a_program"
pyflakes := ""

for _, f := range fs {
t.Run(filepath.Base(f), func(t *testing.T) {
opts := LinterOptions{
Shellcheck: shellcheck,
Pyflakes: pyflakes,
}

linter, err := NewLinter(io.Discard, &opts)
if err != nil {
t.Fatal(err)
}

config := Config{}
linter.defaultConfig = &config

errs, err := linter.LintFile(f, proj)
if err == nil {
t.Fatal("Non existing shellcheck command should fail")
}
_ = errs
})
}
}

func TestLinterPyflakesCommandNotFound(t *testing.T) {
dir := filepath.Join("testdata", "ok")

es, err := os.ReadDir(dir)
if err != nil {
panic(err)
}

fs := make([]string, 0, len(es))
for _, e := range es {
if e.IsDir() {
continue
}
n := e.Name()
if strings.HasSuffix(n, ".yaml") || strings.HasSuffix(n, ".yml") {
fs = append(fs, filepath.Join(dir, n))
}
}

proj := &Project{root: dir}

shellcheck := ""
pyflakes := "i_am_not_a_program"

for _, f := range fs {
t.Run(filepath.Base(f), func(t *testing.T) {
opts := LinterOptions{
Shellcheck: shellcheck,
Pyflakes: pyflakes,
}

linter, err := NewLinter(io.Discard, &opts)
if err != nil {
t.Fatal(err)
}

config := Config{}
linter.defaultConfig = &config

errs, err := linter.LintFile(f, proj)
if err == nil {
t.Fatal("Non existing shellcheck command should fail")
}
_ = errs
})
}
}

func TestLinterLintOK(t *testing.T) {
dir := filepath.Join("testdata", "ok")

Expand Down

0 comments on commit 2d99b21

Please sign in to comment.