Trivadis / plsql-cop-cli

db* CODECOP Command Line
Other
24 stars 1 forks source link

Rationale for exempting INTEGER from G-2110? #6

Closed SiShaman closed 3 years ago

SiShaman commented 3 years ago

I was fiddling around with the command-line version of PL/SQL Cop and some older code, and surprised to not see G-2110 raised for several variables. After further experimentation I worked out that it just doesn't seem to apply to variables declared as INTEGER and I was wondering why. No obvious answer is coming to mind or presenting itself through Google searches on what might be "special" about Oracle's integer type.

PhilippSalvisberg commented 3 years ago

The bad example in https://trivadis.github.io/plsql-and-sql-coding-guidelines/v4.0/4-language-usage/2-variables-and-types/1-general/g-2110/ throws a violation.

To reduce false positives (e.g. for user defined data types) only some chosen data types are considered for the check. Currently:

The rule makes most sense for data types that allow a scale/precision.

SiShaman commented 3 years ago

Thanks for the very rapid response. Would you entertain the possibility of adding integer to that list if I submitted an enhancement request or is the decision to focus on the "sizable" types pretty fixed at this point?

PhilippSalvisberg commented 3 years ago

Nothing is fixed. You have to convince us that it is a good idea. I suggest to contact toolbox@trivadis.com regarding the enhancement request. Thank you.

PhilippSalvisberg commented 3 years ago

And if you do not like the default behavior, you have always the option to override the behavior of a validator check. However, this feature is only available for customers with a PL/SQL Cop license.

SiShaman commented 3 years ago

My employer does have a license, so we may look into that route. Thank you again for your time.

PhilippSalvisberg commented 3 years ago

Excellent. Here's an example validator and corresponding test.

PhilippSalvisberg commented 3 years ago

Question is answered.