Missing spaces can increase costs

CostSoftware AgilityCode Readability

Missing spaces can increase costs

This code insight counts one violation each time :

  • following operators are not surrounder with at least one space: =, += , -=, == , < , > , != , <> , <= , >= , in , not in , is , is not, and , or , not.
  • following elements are not followed by at least one space : comma, semicolon, colon (except slice operator)

5362

Why you should care

  • Always surround these binary operators with a single space on either side: assignment ( = ), augmented assignment ( += , -= etc.), comparisons ( == , < , > , != , <> , <= , >= , in , not in , is , is not ), Booleans ( and , or , not ).

Additional for Highlight :

  • Always put a whitespace immediately after :
    • comma
    • semicolon
    • colon (except when using as slice operator)

Business Impacts

It is recommended to avoid these in order to ensure the code is more readable and cost effective.

Cost

CAST recommendations

References

https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements

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