Skip to content

Commit

Permalink
Add linter to CI pipeline (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Reczek authored Jul 12, 2022
1 parent 2d7ae91 commit 5dbd704
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
version: '3'

tasks:
lint:
cmds:
- golangci-lint run ./...

test:
cmds:
- go test -race -v ./...
Expand Down
4 changes: 1 addition & 3 deletions pkg/scraper/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/scraper/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -179,7 +179,6 @@ func (s *scraper) scrapeStruct(
}

s.scrapeValueFields(v, parentID, level)
return
}

func (s *scraper) scrapeValueFields(
Expand Down
2 changes: 1 addition & 1 deletion pkg/view/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
30 changes: 15 additions & 15 deletions pkg/view/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand All @@ -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<<STYLE>> {
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestNewView_with_component(t *testing.T) {
err := v.RenderStructureTo(s, &out)
require.NoError(t, err)

outString := string(out.Bytes())
outString := out.String()

expectedContent := `
rectangle "==test.Component\n<size:10>[component:technology]</size>\n\ndescription" <<tag 1>> as ID_1
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestNewView_with_relation(t *testing.T) {
err := v.RenderStructureTo(s, &out)
require.NoError(t, err)

outString := string(out.Bytes())
outString := out.String()

expectedContent := `
ID_1 .[#000000].> ID_2 : ""
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestNewView_with_custom_line_color(t *testing.T) {
err := v.RenderStructureTo(s, &out)
require.NoError(t, err)

outString := string(out.Bytes())
outString := out.String()

expectedContent := `
ID_1 .[#ffffff].> ID_2 : ""
Expand Down Expand Up @@ -214,7 +214,7 @@ func TestNewView_with_component_of_view_tag(t *testing.T) {
err := v.RenderStructureTo(s, &out)
require.NoError(t, err)

outString := string(out.Bytes())
outString := out.String()

expectedContent := `
rectangle "==test.Component\n<size:10>[component:technology]</size>\n\ndescription" <<tag 1>> as ID_1
Expand Down Expand Up @@ -243,7 +243,7 @@ func TestNewView_with_component_with_no_view_tag(t *testing.T) {
err := v.RenderStructureTo(s, &out)
require.NoError(t, err)

outString := string(out.Bytes())
outString := out.String()

expectedContent := `ID_1`
require.NotContains(t, outString, expectedContent)
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestNewView_with_two_joined_components_of_view_tag(t *testing.T) {
err := v.RenderStructureTo(s, &out)
require.NoError(t, err)

outString := string(out.Bytes())
outString := out.String()

expectedContent := `
rectangle "==test.Component\n<size:10>[component:technology]</size>\n\ndescription" <<tag 1>> as ID_1
Expand Down Expand Up @@ -337,7 +337,7 @@ func TestNewView_with_two_joined_components_where_one_with_no_view_tag(t *testin
err := v.RenderStructureTo(s, &out)
require.NoError(t, err)

outString := string(out.Bytes())
outString := out.String()

expectedContent := `
rectangle "==test.Component\n<size:10>[component:technology]</size>\n\ndescription" <<tag 1>> as ID_1
Expand Down Expand Up @@ -375,7 +375,7 @@ func TestNewView_with_component_of_custom_style_shape(t *testing.T) {
err := v.RenderStructureTo(s, &out)
require.NoError(t, err)

outString := string(out.Bytes())
outString := out.String()

expectedContent := `
skinparam database<<DB>> {
Expand Down Expand Up @@ -425,7 +425,7 @@ func TestNewView_with_two_joined_components_of_view_root_tag(t *testing.T) {
err := v.RenderStructureTo(s, &out)
require.NoError(t, err)

outString := string(out.Bytes())
outString := out.String()

expectedContent := `
rectangle "==test.Component\n<size:10>[component:technology]</size>\n\ndescription" <<ROOT>> as ID_1
Expand Down Expand Up @@ -477,7 +477,7 @@ func TestNewView_with_two_joined_components_where_one_with_no_view_root_tag(t *t
err := v.RenderStructureTo(s, &out)
require.NoError(t, err)

outString := string(out.Bytes())
outString := out.String()

expectedContent := `ID_1`
require.NotContains(t, outString, expectedContent)
Expand Down Expand Up @@ -516,7 +516,7 @@ func TestNewView_with_component_with_no_connection_to_root(t *testing.T) {
err := v.RenderStructureTo(s, &out)
require.NoError(t, err)

outString := string(out.Bytes())
outString := out.String()

expectedContent := `
rectangle "==test.Component\n<size:10>[component:technology]</size>\n\ndescription" <<ROOT>> as ID_1
Expand Down Expand Up @@ -558,7 +558,7 @@ func TestNewView_creates_grouping(t *testing.T) {
err := v.RenderStructureTo(s, &out)
require.NoError(t, err)

outString := string(out.Bytes())
outString := out.String()

expectedContent := `
rectangle 0ROOT <<_GROUP>> {
Expand Down

0 comments on commit 5dbd704

Please sign in to comment.