diff --git a/.circleci/config.yml b/.circleci/config.yml index 1a346f4..c92403e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,6 +25,9 @@ jobs: - run: name: "Install TaskFile" command: go install github.com/go-task/task/v3/cmd/task@latest + - run: + name: "Lint" + command: task lint - run: name: "Test" command: task test diff --git a/Taskfile.yml b/Taskfile.yml index dcbe5b3..b74529c 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,6 +1,10 @@ version: '3' tasks: + lint: + cmds: + - golangci-lint run ./... + test: cmds: - go test -race -v ./... diff --git a/pkg/scraper/rule.go b/pkg/scraper/rule.go index 9d8b600..c3c31ea 100644 --- a/pkg/scraper/rule.go +++ b/pkg/scraper/rule.go @@ -165,9 +165,7 @@ func NewRule() RuleBuilder { // WithPkgRegexps sets a list of package regular expressions. func (b *ruleBuilder) WithPkgRegexps(rgx ...string) RuleBuilder { - for _, r := range rgx { - b.pkgRegexes = append(b.pkgRegexes, r) - } + b.pkgRegexes = append(b.pkgRegexes, rgx...) return b } diff --git a/pkg/scraper/strategy.go b/pkg/scraper/strategy.go index 98412a0..1154ab0 100644 --- a/pkg/scraper/strategy.go +++ b/pkg/scraper/strategy.go @@ -101,7 +101,7 @@ func (s *scraper) scrapeMapStrategy( s.debug(v, "map scraping strategy applied: each of map elements will be scraped") iterator := v.MapRange() - for true { + for { if !iterator.Next() { break } @@ -179,7 +179,6 @@ func (s *scraper) scrapeStruct( } s.scrapeValueFields(v, parentID, level) - return } func (s *scraper) scrapeValueFields( diff --git a/pkg/view/render.go b/pkg/view/render.go index b747d4c..6321da4 100644 --- a/pkg/view/render.go +++ b/pkg/view/render.go @@ -45,7 +45,7 @@ func (v view) renderBody(s model.Structure) string { v.renderRootComponents(ctx) - for true { + for { ctx.level++ rendered := v.renderNextBodyLayer(ctx) if rendered == 0 { diff --git a/pkg/view/view_test.go b/pkg/view/view_test.go index d209a94..67aa1d4 100644 --- a/pkg/view/view_test.go +++ b/pkg/view/view_test.go @@ -19,7 +19,7 @@ func TestNewView_empty(t *testing.T) { err := v.RenderStructureTo(s, &out) require.NoError(t, err) - outString := string(out.Bytes()) + outString := out.String() expectedContent := `This diagram has been generated with go-structurizr [https://github.com/krzysztofreczek/go-structurizr] @@ -62,7 +62,7 @@ func TestNewView_with_title(t *testing.T) { err := v.RenderStructureTo(s, &out) require.NoError(t, err) - outString := string(out.Bytes()) + outString := out.String() expectedContent := `title TITLE` require.Contains(t, outString, expectedContent) @@ -84,7 +84,7 @@ func TestNewView_with_custom_style(t *testing.T) { err := v.RenderStructureTo(s, &out) require.NoError(t, err) - outString := string(out.Bytes()) + outString := out.String() expectedContent := ` skinparam rectangle<