Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,19 @@ class TrivadisPlsqlNaming extends PLSQLJavaValidator implements PLSQLCopValidato
val parent = p.eContainer
if (!(parent instanceof CursorDeclarationOrDefinition)) {
val name = p.parameter.value.toLowerCase
if (p.in && p.out) {
if (!name.startsWith(PREFIX_IN_OUT_PARAMETER_NAME)) {
warning(ISSUE_IN_OUT_PARAMETER_NAME, p.parameter, p)
}
} else if (p.out) {
if (!name.startsWith(PREFIX_OUT_PARAMETER_NAME)) {
warning(ISSUE_OUT_PARAMETER_NAME, p.parameter, p)
}
} else if (!p.self) {
if (!name.startsWith(PREFIX_IN_PARAMETER_NAME)) {
warning(ISSUE_IN_PARAMETER_NAME, p.parameter, p)
if (name != "self") {
if (p.in && p.out) {
if (!name.startsWith(PREFIX_IN_OUT_PARAMETER_NAME)) {
warning(ISSUE_IN_OUT_PARAMETER_NAME, p.parameter, p)
}
} else if (p.out) {
if (!name.startsWith(PREFIX_OUT_PARAMETER_NAME)) {
warning(ISSUE_OUT_PARAMETER_NAME, p.parameter, p)
}
} else {
if (!name.startsWith(PREFIX_IN_PARAMETER_NAME)) {
warning(ISSUE_IN_PARAMETER_NAME, p.parameter, p)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,23 @@ class TrivadisPlsqlNamingTest extends AbstractValidatorTest {
Assert.assertEquals(0, issues.filter[it.code == "G-9008"].size)
}

@Test
def void SelfInParameterNameOk() {
val stmt = '''
CREATE OR REPLACE TYPE rectangle AUTHID definer AS OBJECT (
rect_length NUMBER,
rect_width NUMBER,
member FUNCTION get_surface (
self IN rectangle
) RETURN NUMBER
);
'''
val issues = stmt.issues
Assert.assertEquals(0, issues.filter[it.code == "G-9008"].size)
}



@Test
def void outParameterNameNok() {
val stmt = '''
Expand Down Expand Up @@ -375,6 +392,22 @@ class TrivadisPlsqlNamingTest extends AbstractValidatorTest {
Assert.assertEquals(0, issues.filter[it.code == "G-9010"].size)
}

@Test
def void SelfInOutParameterNameOk() {
val stmt = '''
CREATE OR REPLACE TYPE rectangle AUTHID definer AS OBJECT (
rect_length NUMBER,
rect_width NUMBER,
CONSTRUCTOR FUNCTION rectangle (
self IN OUT NOCOPY rectangle,
in_length_and_width IN NUMBER
) RETURN SELF AS RESULT
);
'''
val issues = stmt.issues
Assert.assertEquals(0, issues.filter[it.code == "G-9010"].size)
}

@Test
def void recordTypeNameNok() {
val stmt = '''
Expand Down