Minor fixes
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.swift.rule.bestpractices;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.pmd.lang.swift.AbstractSwiftRule;
|
||||
import net.sourceforge.pmd.lang.swift.antlr4.SwiftParser;
|
||||
|
||||
@ -16,7 +21,7 @@ public class UnavailableFunctionRule extends AbstractSwiftRule<Void> {
|
||||
}
|
||||
|
||||
if (shouldIncludeUnavailableModifier(ctx.functionBody().codeBlock())) {
|
||||
SwiftParser.AttributesContext attributes = ctx.functionHead().attributes();
|
||||
final SwiftParser.AttributesContext attributes = ctx.functionHead().attributes();
|
||||
if (attributes == null || !hasUnavailableModifier(attributes.attribute())) {
|
||||
addViolation(data, ctx);
|
||||
}
|
||||
@ -32,7 +37,7 @@ public class UnavailableFunctionRule extends AbstractSwiftRule<Void> {
|
||||
}
|
||||
|
||||
if (shouldIncludeUnavailableModifier(ctx.initializerBody().codeBlock())) {
|
||||
SwiftParser.AttributesContext attributes = ctx.initializerHead().attributes();
|
||||
final SwiftParser.AttributesContext attributes = ctx.initializerHead().attributes();
|
||||
if (attributes == null || !hasUnavailableModifier(attributes.attribute())) {
|
||||
addViolation(data, ctx);
|
||||
}
|
||||
@ -46,7 +51,7 @@ public class UnavailableFunctionRule extends AbstractSwiftRule<Void> {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<SwiftParser.StatementContext> statements = ctx.statements().statement();
|
||||
final List<SwiftParser.StatementContext> statements = ctx.statements().statement();
|
||||
|
||||
return statements.size() == 1 && FATAL_ERROR.equals(statements.get(0).getStart().getText());
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ Rules which enforce generally accepted best practices.
|
||||
since="7.0"
|
||||
message="Unimplemented functions should be marked as unavailable."
|
||||
class="net.sourceforge.pmd.lang.swift.rule.bestpractices.UnavailableFunctionRule"
|
||||
externalInfoUrl="http://pmd.github.io/pmd/pmd_rules_swift_bestpractices.html#unavailablefunctionrule">
|
||||
externalInfoUrl="http://pmd.github.io/pmd/pmd_rules_swift_bestpractices.html#unavailablefunction">
|
||||
<description>
|
||||
Unimplemented functions should be marked as unavailable.
|
||||
</description>
|
||||
<priority>2</priority>
|
||||
<priority>3</priority>
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
@ -1,6 +1,11 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.swift.rule.bestpractices;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class UnavailableFunctionTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
Reference in New Issue
Block a user