Addressed some PR comments

This commit is contained in:
Tomi De Lucca
2019-08-04 15:25:30 -03:00
parent 443be1715f
commit 89ede940d3
5 changed files with 85 additions and 4 deletions

View File

@ -18,7 +18,19 @@ Rules which enforce generally accepted best practices.
Creating views using Interface Builder should be avoided.
Defining views by code allows the compiler to detect issues that otherwise will be runtime errors.
It's difficult to review the auto-generated code and allow concurrent modifications of those files.
Consider building views programmatically.
</description>
<priority>2</priority>
<example>
<![CDATA[
class ViewController: UIViewController {
@IBOutlet var label: UILabel! // violation, referencing a IBOutlet
}
class ViewController: UIViewController {
var label: UILabel!
}
]]>
</example>
</rule>
</ruleset>

View File

@ -18,6 +18,7 @@
<description>
Force casts should be avoided. This may lead to a crash if it's not used carefully.
For example assuming a JSON property has a given type, or your reused Cell has a certain contract.
Consider using conditional casting and handling the resulting optional.
</description>
<priority>3</priority>
<properties>
@ -30,6 +31,13 @@
</property>
<property name="version" value="2.0"/>
</properties>
<example>
<![CDATA[
NSNumber() as! Int // violation, force casting
NSNumber() as? Int // no violation
]]>
</example>
</rule>
<rule name="ForceTry"
@ -40,6 +48,7 @@
externalInfoUrl="http://pmd.github.io/pmd/pmd_rules_swift_errorprone.html#forcetry">
<description>
Force tries should be avoided. If the code being wrapped happens to raise and exception, our application will crash.
Consider using a conditional try and handling the resulting optional, or wrapping the try statement in a do-catch block.
</description>
<priority>3</priority>
<properties>
@ -52,5 +61,12 @@
</property>
<property name="version" value="2.0"/>
</properties>
<example>
<![CDATA[
let x = try! someThrowingFunction() // violation, force trying
let x = try? someThrowingFunction() // no violation
]]>
</example>
</rule>
</ruleset>