Mixed style increases costs when used for a string quote

Software AgilityCode Readability

Why you should care

Be consistent with your choice of string quote character within a file. Pick ‘ or ” and stick with it. It is okay to use the other quote character on a string to avoid the need to \ escape within the string.

Business Impacts

Consistency is key is keeping a maintainable codebase. While there is no practical difference using single or double quotes, is strongly advised to stick with one to avoid confusion and accidental bug creation among developers. A established style also will reduce conflict among the development team and wasted development time with maintenance.

Cost
5362

CAST Recommendations

Establish a clear and consistent style guide for your development team, which makes it clear what is the primary quote type to use, and when exactly it is acceptable to use the alternative.  

How we detect

This code insight computes the number or string using ” and the number of string using ‘. The alert level defined in the model will be in relation with the ratio between them : a 50% ration will be the wortst possible result.

Also :

NSQ = Number of simple Quote
NDQ = Number of Double Quote

Nbr_MixedStringsStyle = int ( 100 * Min(NSQ, NDQ) / (NSQ + NDQ))

bad

 Python("Why are you hiding your eyes?")
 Gollum('The lint. It burns. It burns us.')
 Gollum("Always the great lint. Watching. Watching.")

good

 Python('Why are you hiding your eyes?')
 Gollum("I'm scared of lint errors.")
 Narrator('"Good!" thought a happy Python reviewer.')

5362

About CAST and Highlight’s Code Insights

Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.

See featuresHow it works

c