[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: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">
<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>
"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>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<rule name="TomKytesDespair"
language="plsql"
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[
//ExceptionHandler[QualifiedName/@Image='OTHERS' and upper-case(Statement/UnlabelledStatement/Expression/@Image)='NULL']
]]>
</value>
</property>
</properties>
<example>
</value>
</property>
</properties>
<example>
<![CDATA[
CREATE OR REPLACE PACKAGE BODY update_planned_hrs
IS
PROCEDURE set_new_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER, p_hours IN NUMBER)
IS
BEGIN
UPDATE employee_on_activity ea
SET ea.ea_planned_hours = p_hours
WHERE
ea.ea_emp_id = p_emp_id
ea.ea_emp_id = p_emp_id
AND ea.ea_proj_id = p_project_id;
EXCEPTION
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;
FUNCTION existing_planned (p_emp_id IN NUMBER, p_project_id IN NUMBER) RETURN NUMBER
IS
existing_hours NUMBER(4);
BEGIN
SELECT ea.ea_planned_hours INTO existing_hours
SELECT ea.ea_planned_hours INTO existing_hours
FROM employee_on_activity ea
WHERE
ea.ea_emp_id = p_emp_id
AND ea.ea_proj_id = p_project_id;
ea.ea_emp_id = p_emp_id
AND ea.ea_proj_id = p_project_id;
RETURN (existing_hours);
EXCEPTION
WHEN OTHERS THEN NULL;
END existing_planned;
END update_planned_hrs;
/
]]>
</example>
</rule>
</ruleset>
</example>
</rule>
</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.
</description>
<rule name="TO_DATEWithoutDateFormat"
language="plsql"
since="5.1"
message="TO_DATE without date format"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/rules/plsql/dates.html#TO_DATEWithoutDateFormat">
<description>
TO_DATE without date format- use TO_DATE(expression, date-format)
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<rule name="TO_DATEWithoutDateFormat"
language="plsql"
since="5.1"
message="TO_DATE without date format"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_dates.html#to_datewithoutdateformat">
<description>
TO_DATE without date format- use TO_DATE(expression, date-format)
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![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>
</property>
</properties>
<example>
</value>
</property>
</properties>
<example>
<![CDATA[
CREATE OR REPLACE PACKAGE BODY date_utilities
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
IS
BEGIN
RETURN TO_DATE(p_date_string);
RETURN TO_DATE(p_date_string);
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
IS
BEGIN
TO_DATE(p_date_string, p_date_format);
END to_date_two_parameters ;
TO_DATE(p_date_string, p_date_format);
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
IS
BEGIN
TO_DATE(p_date_string, p_format_mask, p_nls_language);
END to_date_three_parameters ;
TO_DATE(p_date_string, p_format_mask, p_nls_language);
END to_date_three_parameters;
END date_utilities ;
END date_utilities;
/
]]>
</example>
</rule>
</example>
</rule>
<rule name="TO_DATE_TO_CHAR"
language="plsql"
since="5.1"
message="TO_DATE(TO_CHAR(variable)) instead of TRUNC(variable)"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/rules/plsql/dates.html#TO_DATE_TO_CHAR">
<description>
TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-veriable)
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<rule name="TO_DATE_TO_CHAR"
language="plsql"
since="5.1"
message="TO_DATE(TO_CHAR(variable)) instead of TRUNC(variable)"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_dates.html#to_date_to_char">
<description>
TO_DATE(TO_CHAR(date-variable)) used to remove time component - use TRUNC(date-veriable)
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_DATE'
and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1
and .//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_CHAR'
and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1
]
]
//PrimaryExpression
[PrimaryPrefix/Name/@Image='TO_DATE']
[count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1]
[.//PrimaryExpression
[PrimaryPrefix/Name/@Image='TO_CHAR']
[count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1]
]
]]>
</value>
</property>
</properties>
<example>
</value>
</property>
</properties>
<example>
<![CDATA[
CREATE OR REPLACE PACKAGE BODY date_utilities
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
IS
BEGIN
RETURN TO_DATE(TO_CHAR(p_date));
END strip_time ;
RETURN TO_DATE(TO_CHAR(p_date));
END strip_time;
END date_utilities ;
END date_utilities;
/
]]>
</example>
</rule>
</example>
</rule>
<rule name="TO_TIMESTAMPWithoutDateFormat"
language="plsql"
message="TO_TIMESTAMP without date format"
class="net.sourceforge.pmd.lang.rule.XPathRule"
since="5.1"
externalInfoUrl="${pmd.website.baseurl}/rules/plsql/dates.html#TO_TIMESTAMPWithoutDateFormat">
<description>
TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<rule name="TO_TIMESTAMPWithoutDateFormat"
language="plsql"
message="TO_TIMESTAMP without date format"
class="net.sourceforge.pmd.lang.rule.XPathRule"
since="5.1"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_dates.html#to_timestampwithoutdateformat">
<description>
TO_TIMESTAMP without date format- use TO_TIMESTAMP(expression, date-format)
</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//PrimaryExpression[PrimaryPrefix/Name/@Image='TO_TIMESTAMP' and count(PrimarySuffix/Arguments/ArgumentList/Argument) = 1 ]
]]>
</value>
</property>
</properties>
<example>
</value>
</property>
</properties>
<example>
<![CDATA[
CREATE OR REPLACE PACKAGE BODY date_utilities
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
IS
BEGIN
RETURN TO_TIMESTAMP(p_date_string);
END to_timestamp_single_parameter ;
RETURN TO_TIMESTAMP(p_date_string);
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
IS
BEGIN
TO_TIMESTAMP(p_date_string, p_date_format);
END to_timestamp_two_parameters ;
TO_TIMESTAMP(p_date_string, p_date_format);
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
IS
BEGIN
TO_TIMESTAMP(p_date_string, p_format_mask, p_nls_language);
END to_timestamp_three_parameters ;
TO_TIMESTAMP(p_date_string, p_format_mask, p_nls_language);
END to_timestamp_three_parameters;
END date_utilities ;
END date_utilities;
/
]]>
</example>
</rule>
</ruleset>
</example>
</rule>
</ruleset>

View File

@ -2,4 +2,8 @@
# 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.
</description>
<rule name="MisplacedPragma"
language="plsql"
since="5.5.2"
message="Pragma should be used only inside the declaration block before 'BEGIN'."
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/rules/plsql/strictsyntax.html#MisplacedPragma">
<rule name="MisplacedPragma"
language="plsql"
since="5.5.2"
message="Pragma should be used only inside the declaration block before 'BEGIN'."
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_plsql_strictsyntax.html#misplacedpragma">
<description>
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.
@ -22,12 +22,15 @@ https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/static.htm#BABIIHBJ
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
<value>
<![CDATA[
//ProgramUnit/Pragma
]]></value>
]]>
</value>
</property>
</properties>
<example><![CDATA[
<example>
<![CDATA[
create or replace package inline_pragma_error is
end;
@ -44,8 +47,8 @@ create or replace package body inline_pragma_error is
end inline_pragma_error;
/
]]></example>
</rule>
]]>
</example>
</rule>
</ruleset>