Skip to content

New Rule: no unused assigned values #48

Closed
@silviomarghitola

Description

@silviomarghitola

Language Usage / Variables & Types / General
Avoid assigning values to local variables that are not used by a subsequent statement

from SonarQube

Dead stores should be removed

A dead store happens when a local variable is assigned a value that is not read by any subsequent instruction. Calculating or retrieving a value only to then overwrite it or throw it away, could indicate a serious error in the code. Even if it's not an error, it is at best a waste of resources. Therefore all calculated values should be used.

Noncompliant Code Example

declare
  my_user VARCHAR2(30);
  my_date VARCHAR2(30);
begin
  my_user := user();
  my_date := sysdate();
  dbms_output.put_line('User:' || my_user || ', date: ' || my_user);
end;

Compliant Solution

declare
  my_user VARCHAR2(30);
  my_date VARCHAR2(30);
begin
  my_user := user();
  my_date := sysdate();
  dbms_output.put_line('User:' || my_user || ', date: ' || my_date);
end;

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions