rspec/rules/S2471/plsql/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

61 lines
1.1 KiB
Plaintext

== Why is this an issue?
Explicit variable initializations with null values are superfluous, since unassigned variables are implicitly initialized to null.
=== Noncompliant code example
[source,sql]
----
SET SERVEROUTPUT ON
DECLARE
foo PLS_INTEGER := NULL; -- Noncompliant, the null assignation is superfluous
bar VARCHAR2(100) := ''; -- Noncompliant, the null assignation is superfluous
correctInitializedString VARCHAR2(100) := 'Hello world!';
BEGIN
IF foo IS NULL THEN
DBMS_OUTPUT.PUT_LINE('foo is NULL');
ELSE
DBMS_OUTPUT.PUT_LINE('foo is NOT NULL');
END IF;
END;
/
----
=== Compliant solution
[source,sql]
----
SET SERVEROUTPUT ON
DECLARE
foo PLS_INTEGER;
bar VARCHAR2(100);
correctInitializedString VARCHAR2(100) := 'Hello world!';
BEGIN
IF foo IS NULL THEN
DBMS_OUTPUT.PUT_LINE('foo is NULL');
ELSE
DBMS_OUTPUT.PUT_LINE('foo is NOT NULL');
END IF;
END;
/
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove this "NULL" initialization.
endif::env-github,rspecator-view[]