[doc] [plsql] Adjust externalInfoUrl properties to new site - Part 8

Note: I also took the chance to fix tab damage
This commit is contained in:
Andreas Dangel
2017-08-15 11:00:05 +02:00
parent 69267eebdd
commit 9eb3aef9d6
5 changed files with 493 additions and 493 deletions

View File

@ -3,73 +3,74 @@
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"> xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
Rules based on Thomas Kyte's recommendations on http://asktom.oracle.com/ and http://tkyte.blogspot.com/.
</description>
<rule language="plsql" name="TomKytesDespair"
since="5.1"
message="WHEN OTHERS THEN NULL - when you do this, Tom Kyte cries"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/rules/plsql/TomKytesDespair.html#TomKytesDespair">
<description> <description>
"WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR Rules based on Thomas Kyte's recommendations on http://asktom.oracle.com/ and http://tkyte.blogspot.com/.
</description> </description>
<priority>3</priority>
<properties> <rule name="TomKytesDespair"
<property name="xpath"> language="plsql"
<value> since="5.1"
message="WHEN OTHERS THEN NULL - when you do this, Tom Kyte cries"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_TomKytesDespair.html#tomkytesdespair">
<description>
"WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[ <![CDATA[
//ExceptionHandler[QualifiedName/@Image='OTHERS' and upper-case(Statement/UnlabelledStatement/Expression/@Image)='NULL'] //ExceptionHandler[QualifiedName/@Image='OTHERS' and upper-case(Statement/UnlabelledStatement/Expression/@Image)='NULL']
]]> ]]>
</value> </value>
</property> </property>
</properties> </properties>
<example> <example>
<![CDATA[ <![CDATA[
CREATE OR REPLACE PACKAGE BODY update_planned_hrs CREATE OR REPLACE PACKAGE BODY update_planned_hrs
IS IS
PROCEDURE set_new_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER, p_hours IN NUMBER) PROCEDURE set_new_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER, p_hours IN NUMBER)
IS IS
BEGIN BEGIN
UPDATE employee_on_activity ea UPDATE employee_on_activity ea
SET ea.ea_planned_hours = p_hours SET ea.ea_planned_hours = p_hours
WHERE WHERE
ea.ea_emp_id = p_emp_id ea.ea_emp_id = p_emp_id
AND ea.ea_proj_id = p_project_id; AND ea.ea_proj_id = p_project_id;
EXCEPTION EXCEPTION
WHEN NO_DATA_FOUND THEN WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR (-20100, 'No such employee or project'); RAISE_APPLICATION_ERROR (-20100, 'No such employee or project');
END set_new_planned; END set_new_planned;
FUNCTION existing_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER) RETURN NUMBER FUNCTION existing_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER) RETURN NUMBER
IS IS
existing_hours NUMBER(4); existing_hours NUMBER(4);
BEGIN BEGIN
SELECT ea.ea_planned_hours INTO existing_hours SELECT ea.ea_planned_hours INTO existing_hours
FROM employee_on_activity ea FROM employee_on_activity ea
WHERE WHERE
ea.ea_emp_id = p_emp_id ea.ea_emp_id = p_emp_id
AND ea.ea_proj_id = p_project_id; AND ea.ea_proj_id = p_project_id;
RETURN (existing_hours); RETURN (existing_hours);
EXCEPTION EXCEPTION
WHEN OTHERS THEN NULL; WHEN OTHERS THEN NULL;
END existing_planned; END existing_planned;
END update_planned_hrs; END update_planned_hrs;
/ /
]]> ]]>
</example> </example>
</rule> </rule>
</ruleset>
</ruleset>

File diff suppressed because it is too large Load Diff

View File

@ -8,149 +8,150 @@
The Dates ruleset deals with PLSQL DATETIME usages. The Dates ruleset deals with PLSQL DATETIME usages.
</description> </description>
<rule name="TO_DATEWithoutDateFormat" <rule name="TO_DATEWithoutDateFormat"
language="plsql" language="plsql"
since="5.1" since="5.1"
message="TO_DATE without date format" message="TO_DATE without date format"
class="net.sourceforge.pmd.lang.rule.XPathRule" class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/rules/plsql/dates.html#TO_DATEWithoutDateFormat"> externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_dates.html#to_datewithoutdateformat">
<description> <description>
TO_DATE without date format- use TO_DATE(expression, date-format) TO_DATE without date format- use TO_DATE(expression, date-format)
</description> </description>
<priority>3</priority> <priority>3</priority>
<properties> <properties>
<property name="xpath"> <property name="xpath">
<value> <value>
<![CDATA[ <![CDATA[
//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_DATE' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ] //PrimaryExpression[PrimaryPrefix/Name/@Image='TO_DATE' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ]
]]> ]]>
</value> </value>
</property> </property>
</properties> </properties>
<example> <example>
<![CDATA[ <![CDATA[
CREATE OR REPLACE PACKAGE BODY date_utilities CREATE OR REPLACE PACKAGE BODY date_utilities
IS IS
-- Take single parameter, relyimg on current default NLS date format -- Take single parameter, relyimg on current default NLS date format
FUNCTION to_date_single_parameter (p_date_string IN VARCHAR2) RETURN DATE FUNCTION to_date_single_parameter (p_date_string IN VARCHAR2) RETURN DATE
IS IS
BEGIN BEGIN
RETURN TO_DATE(p_date_string); RETURN TO_DATE(p_date_string);
END to_date_single_parameter ; END to_date_single_parameter ;
-- Take 2 parameters, using an explicit date format string -- Take 2 parameters, using an explicit date format string
FUNCTION to_date_two_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2) RETURN DATE FUNCTION to_date_two_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2) RETURN DATE
IS IS
BEGIN BEGIN
TO_DATE(p_date_string, p_date_format); TO_DATE(p_date_string, p_date_format);
END to_date_two_parameters ; END to_date_two_parameters;
-- Take 3 parameters, using an explicit date format string and an explicit language -- Take 3 parameters, using an explicit date format string and an explicit language
FUNCTION to_date_three_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2, p_nls_language VARCHAR2 ) RETURN DATE FUNCTION to_date_three_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2, p_nls_language VARCHAR2 ) RETURN DATE
IS IS
BEGIN BEGIN
TO_DATE(p_date_string, p_format_mask, p_nls_language); TO_DATE(p_date_string, p_format_mask, p_nls_language);
END to_date_three_parameters ; END to_date_three_parameters;
END date_utilities ; END date_utilities;
/ /
]]> ]]>
</example> </example>
</rule> </rule>
<rule name="TO_DATE_TO_CHAR" <rule name="TO_DATE_TO_CHAR"
language="plsql" language="plsql"
since="5.1" since="5.1"
message="TO_DATE(TO_CHAR(variable)) instead of TRUNC(variable)" message="TO_DATE(TO_CHAR(variable)) instead of TRUNC(variable)"
class="net.sourceforge.pmd.lang.rule.XPathRule" class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/rules/plsql/dates.html#TO_DATE_TO_CHAR"> externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_dates.html#to_date_to_char">
<description> <description>
TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-veriable) TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-veriable)
</description> </description>
<priority>3</priority> <priority>3</priority>
<properties> <properties>
<property name="xpath"> <property name="xpath">
<value> <value>
<![CDATA[ <![CDATA[
//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_DATE' //PrimaryExpression
and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 [PrimaryPrefix/Name/@Image='TO_DATE']
and .//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_CHAR' [count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1]
and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 [.//PrimaryExpression
] [PrimaryPrefix/Name/@Image='TO_CHAR']
] [count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1]
]
]]> ]]>
</value> </value>
</property> </property>
</properties> </properties>
<example> <example>
<![CDATA[ <![CDATA[
CREATE OR REPLACE PACKAGE BODY date_utilities CREATE OR REPLACE PACKAGE BODY date_utilities
IS IS
-- Take single parameter, relyimg on current default NLS date format -- Take single parameter, relyimg on current default NLS date format
FUNCTION strip_time (p_date IN DATE) RETURN DATE FUNCTION strip_time (p_date IN DATE) RETURN DATE
IS IS
BEGIN BEGIN
RETURN TO_DATE(TO_CHAR(p_date)); RETURN TO_DATE(TO_CHAR(p_date));
END strip_time ; END strip_time;
END date_utilities ; END date_utilities;
/ /
]]> ]]>
</example> </example>
</rule> </rule>
<rule name="TO_TIMESTAMPWithoutDateFormat" <rule name="TO_TIMESTAMPWithoutDateFormat"
language="plsql" language="plsql"
message="TO_TIMESTAMP without date format" message="TO_TIMESTAMP without date format"
class="net.sourceforge.pmd.lang.rule.XPathRule" class="net.sourceforge.pmd.lang.rule.XPathRule"
since="5.1" since="5.1"
externalInfoUrl="${pmd.website.baseurl}/rules/plsql/dates.html#TO_TIMESTAMPWithoutDateFormat"> externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_dates.html#to_timestampwithoutdateformat">
<description> <description>
TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format) TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
</description> </description>
<priority>3</priority> <priority>3</priority>
<properties> <properties>
<property name="xpath"> <property name="xpath">
<value> <value>
<![CDATA[ <![CDATA[
//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_TIMESTAMP' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ] //PrimaryExpression[PrimaryPrefix/Name/@Image='TO_TIMESTAMP' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ]
]]> ]]>
</value> </value>
</property> </property>
</properties> </properties>
<example> <example>
<![CDATA[ <![CDATA[
CREATE OR REPLACE PACKAGE BODY date_utilities CREATE OR REPLACE PACKAGE BODY date_utilities
IS IS
-- Take single parameter, relyimg on current default NLS date format -- Take single parameter, relyimg on current default NLS date format
FUNCTION to_timestamp_single_parameter (p_date_string IN VARCHAR2) RETURN DATE FUNCTION to_timestamp_single_parameter (p_date_string IN VARCHAR2) RETURN DATE
IS IS
BEGIN BEGIN
RETURN TO_TIMESTAMP(p_date_string); RETURN TO_TIMESTAMP(p_date_string);
END to_timestamp_single_parameter ; END to_timestamp_single_parameter;
-- Take 2 parameters, using an explicit date format string -- Take 2 parameters, using an explicit date format string
FUNCTION to_timestamp_two_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2) RETURN DATE FUNCTION to_timestamp_two_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2) RETURN DATE
IS IS
BEGIN BEGIN
TO_TIMESTAMP(p_date_string, p_date_format); TO_TIMESTAMP(p_date_string, p_date_format);
END to_timestamp_two_parameters ; END to_timestamp_two_parameters;
-- Take 3 parameters, using an explicit date format string and an explicit language -- Take 3 parameters, using an explicit date format string and an explicit language
FUNCTION to_timestamp_three_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2, p_nls_language VARCHAR2 ) RETURN DATE FUNCTION to_timestamp_three_parameters (p_date_string IN VARCHAR2, p_format_mask IN VARCHAR2, p_nls_language VARCHAR2 ) RETURN DATE
IS IS
BEGIN BEGIN
TO_TIMESTAMP(p_date_string, p_format_mask, p_nls_language); TO_TIMESTAMP(p_date_string, p_format_mask, p_nls_language);
END to_timestamp_three_parameters ; END to_timestamp_three_parameters;
END date_utilities ; END date_utilities;
/ /
]]> ]]>
</example> </example>
</rule> </rule>
</ruleset>
</ruleset>

View File

@ -2,4 +2,8 @@
# BSD-style license; for more info see http://pmd.sourceforge.net/license.html # BSD-style license; for more info see http://pmd.sourceforge.net/license.html
# #
rulesets.filenames=rulesets/plsql/codesize.xml,rulesets/plsql/dates.xml,rulesets/plsql/TomKytesDespair.xml,rulesets/plsql/strictsyntax.xml rulesets.filenames=\
rulesets/plsql/codesize.xml,\
rulesets/plsql/dates.xml,\
rulesets/plsql/TomKytesDespair.xml,\
rulesets/plsql/strictsyntax.xml

View File

@ -8,12 +8,12 @@
The Strict Syntax ruleset contains rules that highlight invalid plsql syntax, which works, but should be avoided. The Strict Syntax ruleset contains rules that highlight invalid plsql syntax, which works, but should be avoided.
</description> </description>
<rule name="MisplacedPragma" <rule name="MisplacedPragma"
language="plsql" language="plsql"
since="5.5.2" since="5.5.2"
message="Pragma should be used only inside the declaration block before 'BEGIN'." message="Pragma should be used only inside the declaration block before 'BEGIN'."
class="net.sourceforge.pmd.lang.rule.XPathRule" class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/rules/plsql/strictsyntax.html#MisplacedPragma"> externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_strictsyntax.html#misplacedpragma">
<description> <description>
Oracle states that the PRAQMA AUTONOMOUS_TRANSACTION must be in the declaration block, Oracle states that the PRAQMA AUTONOMOUS_TRANSACTION must be in the declaration block,
but the code does not complain, when being compiled on the 11g DB. but the code does not complain, when being compiled on the 11g DB.
@ -22,12 +22,15 @@ https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/static.htm#BABIIHBJ
<priority>3</priority> <priority>3</priority>
<properties> <properties>
<property name="xpath"> <property name="xpath">
<value><![CDATA[ <value>
<![CDATA[
//ProgramUnit/Pragma //ProgramUnit/Pragma
]]></value> ]]>
</value>
</property> </property>
</properties> </properties>
<example><![CDATA[ <example>
<![CDATA[
create or replace package inline_pragma_error is create or replace package inline_pragma_error is
end; end;
@ -44,8 +47,8 @@ create or replace package body inline_pragma_error is
end inline_pragma_error; end inline_pragma_error;
/ /
]]>
]]></example> </example>
</rule> </rule>
</ruleset> </ruleset>