Reimplement swift rules without @Text

This commit is contained in:
Clément Fournier
2020-04-24 01:05:25 +02:00
parent a857667ef8
commit cf37bba1b4
2 changed files with 19 additions and 24 deletions

View File

@ -25,7 +25,7 @@
<property name="xpath">
<value>
<![CDATA[
//TypeCastingOperator[starts-with(@Text,'as!')]
//TypeCastingOperator[T-bang]
]]>
</value>
</property>
@ -55,7 +55,7 @@ NSNumber() as? Int // no violation
<property name="xpath">
<value>
<![CDATA[
//TryOperator[@Text='try!']
//TryOperator[T-bang]
]]>
</value>
</property>

View File

@ -1,30 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<test-data
xmlns="http://pmd.sourceforge.net/rule-tests"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
<test-code>
<description><![CDATA[
Good example #1
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
<test-data xmlns="http://pmd.sourceforge.net/rule-tests"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
<test-code>
<description>Good example #1</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
func a() throws {}
do {
try a()
} catch {}
]]></code>
<source-type>swift</source-type>
</test-code>
<test-code>
<description><![CDATA[
Bad example #1
]]></description>
<expected-problems>1</expected-problems>
<code><![CDATA[
]]></code>
</test-code>
<test-code>
<description>Bad example #1</description>
<expected-problems>1</expected-problems>
<code><![CDATA[
func a() throws {}
try! a()
]]></code>
<source-type>swift</source-type>
</test-code>
]]></code>
</test-code>
</test-data>