Why do we use PMD rules?

Posted: April 22, 2010 in Uncategorized
Tags: ,

You may wonder why we use PMD rulesets. Remember that to have one code base targeting Android 1.5, 1.6, and 2.x you have to use a minSDK of 3 and targetSDK of 4 in the manifest? So how od you get your IDE to warn you when using certain 1.6 calls when you should be using 1.5 calls?

<rule name="DoNotCodebuildStringDetectOneSix" message="Do not code detect build string as 1.6 but as 1.5" class="net.sourceforge.pmd.rules.XPathRule">
<description>do not use getApplicationInfo().targetSdkVersion use int sdkVersion = Integer.parseInt(Build.VERSION.SDK); instead</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>//Literal[starts-with(@Image,’getApplicationInfo().targetSdkVersion ‘)]</value>
</property>
</properties>
</rule>

That little rule prevents you form using the android 1.6 style of detecting a build string and forces you to use the 1.5 style of detecting a build string

Reblog this post [with Zemanta]
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s