Skip to content

Conversation

casualjim
Copy link
Member

@casualjim casualjim commented Jul 1, 2019

Implements a scanner that is go module aware.
It also loosens the restriction on requiring a main package. Now it accepts the same package syntax other go tools support eg. ./...

fixes #1970
fixes #1911
fixes #1786
fixes #1784
fixes #1681
fixes #1671

contributes to #1724

Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
install tools in gopath on appveyor
`

Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
@codecov
Copy link

codecov bot commented Jul 1, 2019

Codecov Report

Merging #1991 into master will decrease coverage by 0.57%.
The diff coverage is 74.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1991      +/-   ##
==========================================
- Coverage   80.91%   80.34%   -0.58%     
==========================================
  Files          47       46       -1     
  Lines        8066     8161      +95     
==========================================
+ Hits         6527     6557      +30     
- Misses       1043     1099      +56     
- Partials      496      505       +9
Impacted Files Coverage Δ
cmd/swagger/commands/flatten.go 100% <100%> (ø) ⬆️
cmd/swagger/commands/expand.go 87.5% <100%> (ø) ⬆️
codescan/spec.go 59.68% <59.68%> (ø)
codescan/operations.go 64.35% <64.35%> (ø)
cmd/swagger/commands/generate/spec_go111.go 66.66% <66.66%> (ø)
codescan/schema.go 69.51% <69.51%> (ø)
codescan/parameters.go 72.59% <72.59%> (ø)
codescan/responses.go 74.78% <74.78%> (ø)
codescan/application.go 75.07% <75.07%> (ø)
codescan/parser.go 77.7% <77.7%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update beb88f7...b33aa61. Read the comment docs.

}
if req {
su.schema.Discriminator = su.field
} else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elseif: can replace 'else {if cond {}}' with 'else if cond {}' (from gocritic)

}
}
}
return len(includeTags) <= 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sloppyLen: len(includeTags) <= 0 can be len(includeTags) == 0 (from gocritic)

if current.Type == TypeBool {
current.Type = TypeBoolean
}
} else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elseif: can replace 'else {if cond {}}' with 'else if cond {}' (from gocritic)

}
}

return

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naked return in func collectScannerTitleDescription with 32 lines of code (from nakedret)


// all parsed, returning...
sp.yamlSpec = nil // spec is now consumed, so let's erase the parsed lines
return

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naked return in func UnmarshalSpec with 43 lines of code (from nakedret)

}

//TODO: Maybe do, if !parsedModelOrResponse {return some error}
return

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naked return in func parseTags with 70 lines of code (from nakedret)

type scanCtx struct {
pkgs []*packages.Package
app *typeIndex
builder *specBuilder

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

builder is unused (from structcheck)

}

func (pt paramTypable) AddExtension(key string, value interface{}) {
pt.AddExtension(key, value)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SA5007: infinite recursive call (from staticcheck)

fix some linting issues

Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
@casualjim casualjim marked this pull request as ready for review July 1, 2019 04:10
Signed-off-by: Ivan Porto Carrero <ivan@flanders.co.nz>
@@ -436,6 +436,10 @@ func TestShared_Issue1429(t *testing.T) {
log.SetOutput(ioutil.Discard)
defer log.SetOutput(os.Stdout)

if runtime.GOOS == "windows" {
t.Skip("on windows till the bug is resolved for ref resolution")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok this one is on my plate. I introduced a regression in go-openapi/analysis when running on windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants