Addressed some PR comments
This commit is contained in:
@ -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>
|
||||
|
@ -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>
|
Reference in New Issue
Block a user