Skip to content

Make sketch filename matching rule case-sensitive #162

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

Merged
merged 3 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ require (
go.bug.st/relaxed-semver v0.0.0-20190922224835-391e10178d18
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.14.0 // indirect
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 // indirect
golang.org/x/mod v0.4.0 // indirect
golang.org/x/mod v0.4.1 // indirect
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 // indirect
golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d // indirect
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,8 @@ golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0 h1:8pl+sMODzuvGJkmj2W4kZihvVb5mKm8pB/X44PIQHv8=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180816102801-aaf60122140d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -1383,10 +1385,6 @@ golang.org/x/tools v0.0.0-20200117220505-0cba7a3a9ee9/go.mod h1:TB2adYChydJhpapK
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200203215610-ab391d50b528/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200308013534-11ec41452d41/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/tools v0.0.0-20201210181237-6d345e82f1d8 h1:Pg9rlomzMhg26WdvwSujvC1Pr2lxOfFfhnQ+/LQcjLw=
golang.org/x/tools v0.0.0-20201210181237-6d345e82f1d8/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58 h1:1Bs6RVeBFtLZ8Yi1Hk07DiOqzvwLD/4hln4iahvFlag=
golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201211192254-72fbef54948b h1:8fYBhX5ZQZtb7nVKo58TjndJwMM+cOB1xOnfjgH3uiY=
golang.org/x/tools v0.0.0-20201211192254-72fbef54948b/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
21 changes: 13 additions & 8 deletions internal/rule/rulefunction/sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,20 @@ import (

// SketchNameMismatch checks for mismatch between sketch folder name and primary file name.
func SketchNameMismatch() (result ruleresult.Type, output string) {
for extension := range globals.MainFileValidExtensions {
validPrimarySketchFilePath := projectdata.ProjectPath().Join(projectdata.ProjectPath().Base() + extension)
exist, err := validPrimarySketchFilePath.ExistCheck()
if err != nil {
panic(err)
}
primarySketchFilePrefix := projectdata.ProjectPath().Base()

if exist {
return ruleresult.Pass, ""
directoryListing, err := projectdata.ProjectPath().ReadDir()
if err != nil {
panic(err)
}
directoryListing.FilterOutDirs()

for _, filePath := range directoryListing {
for extension := range globals.MainFileValidExtensions {
if filePath.Base() == primarySketchFilePrefix+extension {
// There was a case-sensitive match (paths package's Exist() is not always case-sensitive, so can't be used here).
return ruleresult.Pass, ""
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion internal/rule/rulefunction/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func checkSketchRuleFunction(ruleFunction Type, testTables []sketchRuleFunctionT
func TestSketchNameMismatch(t *testing.T) {
testTables := []sketchRuleFunctionTestTable{
{"Valid", "Valid", ruleresult.Pass, ""},
{"Mismatch", "NameMismatch", ruleresult.Fail, ""},
{"Name Mismatch", "NameMismatch", ruleresult.Fail, ""},
{"Case Mismatch", "CaseMismatch", ruleresult.Fail, ""},
}

checkSketchRuleFunction(SketchNameMismatch, testTables, t)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
void setup() {}
void loop() {}