Skip to content
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

Reduce code complexity #487

Merged
merged 2 commits into from
Aug 6, 2019
Merged

Reduce code complexity #487

merged 2 commits into from
Aug 6, 2019

Conversation

ubogdan
Copy link
Contributor

@ubogdan ubogdan commented Aug 5, 2019

Describe the PR
code-refactoring

$ ~/go/bin/gocyclo -over 15 .
48 swag (*Parser).parseField parser.go:1010:1
46 swag (*Parser).ParseGeneralAPIInfo parser.go:177:1
33 swag (*Parser).parseStructField parser.go:764:1
16 swag (*Operation).parseAndExtractionParamAttribute operation.go:233:1

Relation issue
None

Additional context
Original results

Gocyclo calculates cyclomatic complexities of functions in Go source code. The cyclomatic complexity of a function is calculated according to the following rules: 1 is the base complexity of a function +1 for each 'if', 'for', 'case', '&&' or '||' Go Report Card warns on functions with cyclomatic complexity > 15.

swag/parser.go
Line 177: warning: cyclomatic complexity 83 of function (*Parser).ParseGeneralAPIInfo() is high (> 15) (gocyclo)
Line 1081: warning: cyclomatic complexity 48 of function (*Parser).parseField() is high (> 15) (gocyclo)
Line 834: warning: cyclomatic complexity 23 of function (*Parser).parseStruct() is high (> 15) (gocyclo)
Line 694: warning: cyclomatic complexity 22 of function (*Parser).parseTypeExpr() is high (> 15) (gocyclo)
Line 1017: warning: cyclomatic complexity 17 of function (*Parser).parseAnonymousField() is high (> 15) (gocyclo)
swag/operation.go
Line 241: warning: cyclomatic complexity 29 of function (*Operation).parseAndExtractionParamAttribute() is high (> 15) (gocyclo)
Line 60: warning: cyclomatic complexity 27 of function (*Operation).ParseComment() is high (> 15) (gocyclo)

@codecov-io
Copy link

codecov-io commented Aug 5, 2019

Codecov Report

Merging #487 into master will increase coverage by 1.12%.
The diff coverage is 84.74%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #487      +/-   ##
=========================================
+ Coverage   86.58%   87.7%   +1.12%     
=========================================
  Files           7       7              
  Lines        1558    1489      -69     
=========================================
- Hits         1349    1306      -43     
+ Misses        120     104      -16     
+ Partials       89      79      -10
Impacted Files Coverage Δ
operation.go 95.45% <100%> (+0.36%) ⬆️
parser.go 82.59% <81.17%> (+1.52%) ⬆️

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 3d60281...cb8d131. Read the comment docs.

Copy link
Member

@easonlin404 easonlin404 left a comment

Choose a reason for hiding this comment

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

LGTM

@easonlin404 easonlin404 merged commit 8743381 into master Aug 6, 2019
@easonlin404 easonlin404 deleted the code-refactoring branch August 6, 2019 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants