Short Generic Names: Damages Readability: squid:S00119

682 views
Skip to first unread message

Marvi...@gtcgroup.com

unread,
Dec 22, 2017, 11:10:48 AM12/22/17
to SonarLint

Type parameter names should comply with a naming convention (squid:S00119)


Although widely practiced... the notion of having short generic names interferes with code "Readability".  I have been hands on coding for 30 years and cannot figure out why the idea of one (or potentially two) character generics ever was popular? Here is the rule in question that we would like you to remove:

Rename this generic name to match the regular expression '^[A-Z][0-9]?$'.

Tibor Blenessy

unread,
Jan 5, 2018, 3:21:23 AM1/5/18
to Marvi...@gtcgroup.com, SonarLint
Hello,

this rule is just enforcing widely used practice to distinguish type variables from other identifiers in the code. This is recommended in all Java code styles I am aware of (see Java tutorial for example https://docs.oracle.com/javase/tutorial/java/generics/types.html ). While I understand your concern about readability, this is so widely practiced that your code would be actually less readable if you start to use some other convention.

However, if you configure SonarLint in connected mode with your SonarQube server you will be able to configure the regex used to check generic names or disable the rule completely.

Hope that helps,

Tibor



--
You received this message because you are subscribed to the Google Groups "SonarLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarlint+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarlint/65f701fa-b391-46ee-9afb-dcbc227e90ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Tibor Blenessy | SonarSource

SonarJava Developer

https://sonarsource.com 

Reply all
Reply to author
Forward
0 new messages