Adding periods to RSPEC-1192 exceptions

Hi,
Rule RSPEC-1192 allows strings with only letters, numbers, underscores and hyphens. Is there an easy way to add periods to the exception char list? It’s very common the use of periods as separator for identifiers, like in ‘table.column’.

KR,

Carlos

Hey there.

Can you confirm which language you’re referring to? And can you double-check the Rule ID? RSPEC-1192 is String literals should not be duplicated, and I’m not sure what exceptions you’d be referring to for this rule.

Hi Colin,
sorry for the delayed answer.
Yes, that is the right rule, applied in PHP. It’s really frequent to use identifiers like ‘table.column’ as indexes for arrays, or parámeters in ORMs, and, as identifiers, makes no sense to declare as constants. At certain point between release 6 and 8 that rule was changed to include underscores and hyphens, but periods where forgotten.
I use Laravel as framework and the use of literals with periods are really frequent, and don’t want to exclude the rule just because of that.

KR,

Carlos

The rule is the same in PHP
String literals should not be duplicated

And the sample code in Exceptions explains exactly where periods are used to build complex identifiers:

$database = config(‘connections.read.database’);

It seems that, as a smart way to detect identifiers may be the lack of spaces in long literals.

Hey guys! Any tip on how to manage the periods issue with this rule? Any sample on how to do something similar?

KR,

Carlos

Hi @Carlos_Mora,

Indeed, periods should also be a valid character to part of an exception of this rule. Therefore, I created this ticket to adapt the specification and implementation of this rule. Thanks for your input and clarification.

Best,
Nils

1 Like

Great! Thanks a lot!

KR,

Carlos

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.