3110Y / cc-profile

3 stars 0 forks source link

Solve code complexity #7

Open marcelloh opened 10 months ago

marcelloh commented 10 months ago

Please read this: https://dev.to/marcello_h/solve-code-complexity-in-go-56hg

Here's the result of my linter:

internal/application/validator/profileValidator.go:33:1 - ValidPassword has complexity: 13
  complexity = 1
  + 1 (found 'missing or wrong comment for function with more that 10 lines' at line: 33, complexity = 2)
  + 1 (found 'if' at line: 34, complexity = 3)
  + 1 (found 'range' at line: 39, complexity = 4)
  + 1 (found 'range with (10) lines >= 10 ' at line: 39, complexity = 5)
    + 2 (found 'if' at line: 40, complexity = 7)
    + 2 (found 'logical operator (1 times) && (AND)' at line: 40, complexity = 8)
    + 2 (found 'else' at line: 42, complexity = 10)
    + 2 (found 'if' at line: 45, complexity = 12)
      + 3 (found 'logical operator (1 times) && (AND)' at line: 45, complexity = 13)

internal/infrastructure/database/database.go:27:1 - NewConnectTest has complexity: 2
  complexity = 1
  + 1 (found 'line-complexity of 6 (max: 5 is allowed)' at line: 28, complexity = 2)

internal/infrastructure/di/wire.go:42:1 - InitializeDI has complexity: 5
  complexity = 1
  + 1 (found 'missing or wrong comment for function with more that 10 lines' at line: 42, complexity = 2)
  + 1 (found 'block with (13) lines >= 5 ' at line: 43, complexity = 3)
  + 1 (found 'block with (13) lines >= 10 ' at line: 43, complexity = 4)
  + 1 (found 'line-complexity of 13 (max: 5 is allowed)' at line: 43, complexity = 5)

21 = files
52 = functions
166 = function lines
13 = highest complexity
2.40 = overall average complexity per function
2 = complex lines
internal/application/validator/profileValidator.go:33:1 - ValidPassword has complexity: 13

busy for: 4.590917ms
3110Y commented 10 months ago

Can I ask you to send me an article on setting up linters? From the attached article I understood why they need to be followed, and not how to set them up)

3110Y commented 10 months ago

And thank you very much)