Skip to content

Are string literals in method arguments considered as LOC ? #6404

Closed Answered by cortinico
nanafan93 asked this question in Q&A
Discussion options

You must be logged in to vote

String literals as method parameters seem to trigger the LongMethod rule ?

Yes they do, we just check the lines of code size of a method to trigger that rule.

As for your specific example, you probably want to either:

  1. Move this string to a variable
  2. Suppress LongMethod for tests using an exclude directive in your config file
  3. Suppress LongMethod for tests using the ignoreAnnotated suppressors (see here https://detekt.dev/docs/next/introduction/suppressors/#annotation-suppressor)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nanafan93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants