Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Rule: don't self-assign variables or columns #34

Closed
silviomarghitola opened this issue Jun 3, 2019 · 4 comments
Closed

New Rule: don't self-assign variables or columns #34

silviomarghitola opened this issue Jun 3, 2019 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@silviomarghitola
Copy link

Language Usage / General
never assign a column or variable to itself

@PhilippSalvisberg
Copy link
Collaborator

from SonarSource:

Variables and columns should not be self-assigned

here is no reason to re-assign a variable to itself. Either this statement is redundant and should be removed, or the re-assignment is a mistake and some other value or variable was intended for the assignment instead.

Noncompliant Code Example

UPDATE person
SET name = name;

Compliant Solution

UPDATE person
SET name = UPPER(name);

@PhilippSalvisberg
Copy link
Collaborator

makes sense.

Notes: All assignments should be considered for the PL/SQL Cop check.

@PhilippSalvisberg PhilippSalvisberg added the enhancement New feature or request label Jun 4, 2019
@PhilippSalvisberg PhilippSalvisberg added this to the v4.0 milestone Jun 4, 2019
@RichardSoule
Copy link

As an aside, one exception would be when attempting to fire cross edition triggers when using Edition Based Redefinition. You may (or may not) want to include that exception.

@kibeha kibeha self-assigned this Sep 23, 2020
@kibeha
Copy link
Collaborator

kibeha commented Oct 7, 2020

Made it two rules:

  • One for variable self-assignment using "Never".
  • One for column self-assignment using "Avoid" and mentioning the trigger firing exception.

@kibeha kibeha closed this as completed in a27e09e Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants