Boeing / config-file-validator

Cross Platform tool to validate configuration files
https://boeing.github.io/config-file-validator/
Apache License 2.0
324 stars 55 forks source link

Fix gocyclo findings for fsfinder #118

Closed kehoecj closed 6 months ago

kehoecj commented 6 months ago

From go report card

Refactor the findOne method to reduce its cyclomatic complexity from 16 to under 15.

HakanVardarr commented 6 months ago

When I ran gocyclo over the fsfinder.go I got this

❯ gocyclo -over 15  ./pkg/finder/fsfinder.go
❯ gocyclo ./pkg/finder/fsfinder.go
13 finder (FileSystemFinder).findOne ./pkg/finder/fsfinder.go:104:1
6 finder (FileSystemFinder).Find ./pkg/finder/fsfinder.go:78:1
2 finder FileSystemFinderInit ./pkg/finder/fsfinder.go:58:1
1 finder WithDepth ./pkg/finder/fsfinder.go:53:1
1 finder WithExcludeFileTypes ./pkg/finder/fsfinder.go:46:1
1 finder WithExcludeDirs ./pkg/finder/fsfinder.go:39:1
1 finder WithFileTypes ./pkg/finder/fsfinder.go:32:1
1 finder WithPathRoots ./pkg/finder/fsfinder.go:25:1

It is already under 15? Did I run the gocyclo wrong?

kehoecj commented 6 months ago

When I ran gocyclo over the fsfinder.go I got this

❯ gocyclo -over 15  ./pkg/finder/fsfinder.go
❯ gocyclo ./pkg/finder/fsfinder.go
13 finder (FileSystemFinder).findOne ./pkg/finder/fsfinder.go:104:1
6 finder (FileSystemFinder).Find ./pkg/finder/fsfinder.go:78:1
2 finder FileSystemFinderInit ./pkg/finder/fsfinder.go:58:1
1 finder WithDepth ./pkg/finder/fsfinder.go:53:1
1 finder WithExcludeFileTypes ./pkg/finder/fsfinder.go:46:1
1 finder WithExcludeDirs ./pkg/finder/fsfinder.go:39:1
1 finder WithFileTypes ./pkg/finder/fsfinder.go:32:1
1 finder WithPathRoots ./pkg/finder/fsfinder.go:25:1

It is already under 15? Did I run the gocyclo wrong?

Looks like it got simplified since v1.5.0 release - most likely though #115 . Thanks for doing the legwork to determine this is no longer an issue