forked from drewbourne/mockolate
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pmd-ruleset.xml
902 lines (872 loc) · 38.1 KB
/
pmd-ruleset.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
<ruleset name="All Flex Rules" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd" xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description/>
<rule since="" class="com.adobe.ac.pmd.rules.architecture.ViewComponentReferencedInModelRule" message="A view component should not be referenced in a model class">
<description/>
<priority>3</priority>
<example><![CDATA[package com.adobe.ac
{
import mx.controls.ComboBox; // VIOLATION
public class MyModelClass
{
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.architecture.MonkeyPatchingRule" message="This class looks to be duplicated with a SDK class">
<description>Monkey patching can be a risky undertaking because it is not using intended extensibility points and thus may have unintended consequences or make migration to newer versions of the SDK more difficult</description>
<priority>1</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.architecture.UseInternalClassOutsideApiClass" message="This class imports an internal class ({0}) from another function area ({1})">
<description>If you have different functionalities, you probably don't want every class of each to be accessible from any other functional areas.
So you probably want to use this packaging:
[org].[project].func1.api
[org].[project].func1.restricted
[org].[project].func2.api
[org].[project].func2.restricted
This rule makes sure that no restricted classes is accessed from outside its own function area.</description>
<priority>1</priority>
<example><![CDATA[package functional
{
import functional.func1.api.Func1ExposedClass;
import functional.func1.restricted.Func1RestrictedClass; // VIOLATION
import functional.func2.api.Func2ExposedClass;
import functional.func2.restricted.Func2RestrictedClass; // VIOLATION
public class FunctionClient
{
}
}
package functional.func1.api
{
import functional.func1.restricted.Func1RestrictedClass;
import functional.func2.api.Func2ExposedClass;
import functional.func2.restricted.Func2RestrictedClass; // VIOLATION
public class Func1ExposedClass
{
}
}
package functional.func1.restricted
{
import functional.func1.api.Func1ExposedClass;
import functional.func2.api.Func2ExposedClass;
import functional.func2.restricted.Func2RestrictedClass; // VIOLATION
public class Func1RestrictedClass
{
}
}
package functional.func2.api
{
import functional.func1.api.Func1ExposedClass;
import functional.func1.restricted.Func1RestrictedClass; // VIOLATION
import functional.func2.restricted.Func2RestrictedClass;
public class Func2ExposedClass
{
}
}
package functional.func2.restricted
{
import functional.func1.api.Func1ExposedClass;
import functional.func1.restricted.Func1RestrictedClass; // VIOLATION
import functional.func2.api.Func2ExposedClass;
public class Func2RestrictedClass
{
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.asdocs.AttributeAsDocMissingRule" message="This attribute ({0}) should be documented with AsDocs.">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.asdocs.ClassAsDocMissingRule" message="This class ({0}) should be documented with AsDocs.">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.asdocs.MethodAsDocMissingRule" message="This method ({0}) should be documented with AsDocs.">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.mxml.MoreThanOneEntryPointInMxmlRule" message="There is more than 1 public variable in this MXML component">
<description/>
<priority>5</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.mxml.MoreThanTwoEntryPointsInMxmlRule" message="There are more than 2 public variables in this MXML component">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.mxml.TooLongScriptBlockRule" message="This script block is too long ({0} maximum, but {1} actually)">
<description/>
<priority>3</priority>
<properties>
<property name="maximum">
<value>50</value>
</property>
</properties>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.mxml.CodeBehindInMxmlRule" message="Avoid using code behind files">
<description>Code behind files are tightly coupled with the view, not unit-testable, not easy to navigate the code code base and not reusable. Try using presentation model pattern, or observer pattern</description>
<priority>5</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.binding.BindingUtilsRule" message="BindingUtils class uses hard coded strings, which won't be picked up by the compiler if you rename this attribute. You should probably consider refactoring using events">
<description/>
<priority>1</priority>
<example><![CDATA[public class Controller extends FrontController
{
public function Controller()
{
BindingUtils.bindSetter(setContent, value, "content"); // VIOLATION
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.binding.ChangeWatcherRule" message="ChangeWatcher class uses hard coded strings to specify the attribute name, to listen to. Prefer listening to events or setters">
<description/>
<priority>1</priority>
<example><![CDATA[public final class Title
{
private var watcher : ChangeWatcher; // VIOLATION
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.binding.TooLongBindingExpressionRule" message="This binding expression is too long ({0} dots maximum, but {1} actually)">
<description>A Binding expression is executed as soon as one of the bindable attributes changed. If a binding expression contains too many expression, there could be some performance issue.</description>
<priority>3</priority>
<properties>
<property name="maximum">
<value>3</value>
</property>
</properties>
<example><![CDATA[
<mx:Label text="{ vfrfr.frfr.frf.lala }"/> <!-- Violation-->
]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.cairngorm.BindableModelLocatorRule" message="A modelLocator must not be Bindable at a class level">
<description>A bindable ModelLocator could leads to performance issues due to bindings</description>
<priority>1</priority>
<example><![CDATA[[Bindable]
public class BindableModelLocator // VIOLATION
{
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.cairngorm.ReferenceModelLocatorOutsideTheMainApplicationRule" message="The ModelLocator should be only accessible from the main application file">
<description>The ModelLocator should be only accessible from the main application file. Then sub-models should be injected to the nested views.</description>
<priority>3</priority>
<example><![CDATA[package business
{
import model.MyModelLocator; // VIOLATION
public class MyBusinessClass
{
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.cairngorm.FatControllerRule" message="A FrontController must nor add all its commands within the Controller constructor">
<description>Try split them into methods where you add commands depending on their functional area.</description>
<priority>3</priority>
<example><![CDATA[package control
{
import control.GetItems1Command;
import control.GetItems1Event;
import control.GetItems2Command;
import control.GetItems2Event;
// A lot of other imports
public class MyFrontController // VIOLATION
{
public function MyFrontController()
{
addCommand(
GetItems1Event.EVENT_NAME,
GetItems1Command );
addCommand(
GetItems2Event.EVENT_NAME,
GetItems2Command );
// A lot of other addCommand
}
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.cairngorm.BadCairngormEventNameFormatRule" message="A Cairngorm event name should contain the function area name before the actual event name">
<description>You would have something like 'productManagement.getProducts' as an event name.</description>
<priority>3</priority>
<example><![CDATA[public class UncorrectConstructorEvent extends CairngormEvent
{
public function UncorrectConstructorEvent( model : IModel )
{
super( "eventName", model ); // VIOLATION. It should be "functionalArea.eventName" instead
}
}
public class UncorrectConstantEvent extends CairngormEnterpriseEvent
{
public static const EVENT_NAME : String = "eventName";
public function UncorrectConstantEvent( model : IModel )
{
super( EVENT_NAME, model ); // VIOLATION
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.cairngorm.CairngormEventDispatcherCallExplicitlyRule" message="CairngormEventDispatcher is called explicitly. {0}">
<description/>
<priority>3</priority>
<example><![CDATA[
public function foo() : void
{
CairngormEventDispatcher.getInstance().dispatchEvent(new Event(CONSTANT)); // VIOLATION <- use cairngormEvent.dispatch();
CairngormEventDispatcher.getInstance().addEventListener(CONSTANT, onHearing); // VIOLATION <- MVC broken
}
]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.cairngorm.ModelLocatorReferencedMoreThanOncePerClassRule" message="Only one reference of ModelLocator is allowed per class">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.component.UpdateChildrenNumberInUpdateDisplayListRule" message="Flex specific - Do not add or remove displayable children from updateDisplayList">
<description>UpdateDisplayList is called everytime a child is invalidated. So calling addChild or removeChild in this function could be really CPU consuming</description>
<priority>1</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.component.CallLaterDirectlyRule" message="Flex specific - Don't call 'callLater' explicitly">
<description>If you needed to call 'callLater' explicitly, then you probably did not extend the correct component life cycle.</description>
<priority>1</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.css.StyleBlockInMxmlRule" message="The style block is embed in the MXML file">
<description>It is not a good practice to embed style blocks inside the MXML component. Prefer using external CSS files.</description>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.css.UseCssInsteadOfEmbedMetaDataRule" message="Embed metadata detected in source code where a stylesheet may be cleaner">
<description/>
<priority>5</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.empty.EmptyCatchStatementRule" message="This catch statement is empty">
<description/>
<priority>3</priority>
<example><![CDATA[public class Foo
{
public function bar( x : int ) : void
{
try
{
}
catch( e : Exception ) // VIOLATION
{
}
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.empty.EmptyIfStmtRule" message="No statements in this if statement">
<description>Empty If Statement finds instances where a condition is checked but nothing is done about it.</description>
<priority>3</priority>
<example><![CDATA[public class Foo
{
public function bar( x : int ) : void
{
if ( x == 0 )
{
// VIOLATION
}
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.event.EventMissingCloneFunctionRule" message="The clone event must be overiden in a custom event">
<description>When creating your own custom Event class, you must override the inherited Event.clone() method in order for it to duplicate the properties of your custom class. If you do not set all the properties that you add in your event subclass, those properties will not have the correct values when the event is cloned. This is important because the Flex SDK clones events whenever redispatching takes place.</description>
<priority>1</priority>
<example><![CDATA[public class FirstCustomEvent // VIOLATION - clone method is missing
{
public var lala : String;
public function FirstCustomEvent()
{
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.event.PublicVariableInCustomEventRule" message="No public variables should be inside a custom event. This variable ({0}) is public">
<description>In order to improve encapsulation in your custom event, it is better not to have public variable in your event. Prefer having read-only attributes, set by the event constructor.</description>
<priority>3</priority>
<example><![CDATA[public class FirstCustomEvent
{
public var lala : String; // VIOLATION
public function FirstCustomEvent()
{
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.event.ConstructorDispatchingEventRule" message="An event is dispatched in a constructor">
<description>This is pointless, since event listeners cannot be attached to an object before it has been constructed, so nothing can ever hear the event</description>
<priority>1</priority>
<example><![CDATA[public class BigModel
{
public function BigModel()
{
dispatchEvent( new Event( "pointlessEvent" ) );
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.event.DefaultEventNameRule" message="Event name should be set explicitly">
<description/>
<priority>3</priority>
<example><![CDATA[public class DefaultNameEvent extends Event
{
public function DefaultNameEvent( type : String = "" )
{
super( type );
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.event.DispatchHardCodedEventNameRule" message="DispatchEvent function must dispatch constant strings">
<description>You should not dispatch a plain string. If you rename this string, you need to replace the string listener as well. Use constants instead</description>
<priority>1</priority>
<example><![CDATA[public class Foo
{
public function bar() : void
{
dispatch( new Event( "myHardCodedEvent" ) ); // VIOLATION
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.event.ListenForHardCodedEventNameRule" message="addEventListener must not contain hard coded strings">
<description>You should not listen for a plain string. If you rename this string, you need to replace the string listener as well. Use constants instead</description>
<priority>1</priority>
<example><![CDATA[public class Foo
{
public function bar() : void
{
addEventListener( "myHardCodedEvent", handleMyHardCodedEvent ); // VIOLATION
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.event.UnboundTypeInMetadataRule" message="This type ({0}) was not found within the scope against which PMD was run">
<description/>
<priority>1</priority>
<example><![CDATA[[Event(name="myTypeEvent",type="UnknownType")] // VIOLATION
public class UnboundMetadata
{
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.event.UntypedEventMetadataRule" message="This event type is not specified">
<description>Specifying a type will allow Flash builder and the class to have this event exposed in its API</description>
<priority>3</priority>
<example><![CDATA[[Event(name="myTypeEvent")] // VIOLATION
public class UnTypedMetadata
{
}]]></example>
</rule>
<rule since="1.1" class="com.adobe.ac.pmd.rules.maintanability.OnlyOneReturnRule" message="A method should have only one exit point, and that should be the last statement in the method">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.maintanability.AlertShowRule" message="Do not call Alert.show directly">
<description>You should not Alert.show() directly. If an error occurred in the system, you should probably use an ErrorManager to have a consistent way to manage those errors.</description>
<priority>1</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.maintanability.ExcessiveImportRule" message="A high number of imports can indicate a high degree of coupling within an object. ({0} maximum but {1} actually)">
<description>A high number of imports can indicate a high degree of coupling within an object. Rule counts the number of unique imports and reports a violation if the count is above the user defined threshold.</description>
<priority>3</priority>
<properties>
<property name="maximum">
<value>15</value>
</property>
</properties>
<example><![CDATA[import blah.blah.Baz;
import blah.blah.Bif;
// 18 others from the same package elided
public class Foo
{
public function doWork() : void
{
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.maintanability.TrueFalseConditionRule" message="This test contains a hard coded boolean value. You could remove it by having '{0}'">
<description/>
<priority>3</priority>
<example><![CDATA[if ( true ) // VIOLATION
{
if ( myCondition == false ) // VIOLATION
{
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.maintanability.AvoidUsingPublicStaticFieldRule" message="If this field ({0}) was meant to be a constant, make it constant. Otherwise, if it is used as a global variable, you may want to redesign this class">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.maintanability.NonStaticConstantFieldRule" message="A constant field should be static ({0})">
<description/>
<priority>1</priority>
<example><![CDATA[public class MyObject {
public static const MY_STATIC_CONSTANT : String = "myStaticConstant";
public const MY_NON_STATIC_CONSTANT : String = "myStaticConstant"; // VIOLATION
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.maintanability.UselessOverridenFunctionRule" message="This method is empty. This should be removed ({0})">
<description>This function is not needed.</description>
<priority>3</priority>
<example><![CDATA[override protected function createChildren() : void
{
super.createChildren();
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.maintanability.AvoidProtectedFieldInFinalClassRule" message="Protected accessors are useless in a final class. Make it private ({0})">
<description/>
<priority>3</priority>
<example><![CDATA[final public class Foo
{
protected var bar : int; // VIOLATION
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.maintanability.AvoidUsingWithKeyWordRule" message="You should not use the with keyword. It does not help readability">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.maintanability.ArrayFieldWithNoArrayElementTypeRule" message="ArrayElementType metadata is not specified for this array-type field ({0})">
<description/>
<priority>3</priority>
<example><![CDATA[public class ArrayVO {
public var items:Array; //VIOLATION
[ArrayElementType("model.vo.MenuItemVO")]
public var menuItems : Array;
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.maintanability.ClassAndExtensionAreIdenticalRule" message="The extension name is the same as the class name">
<description/>
<priority>3</priority>
<example><![CDATA[package com.MyCompany
{
public class SomeClass extends mx.SomeClass // VIOLATION
{
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.maintanability.ProtectedStaticMethodRule" message="This method ({0}) should be private">
<description/>
<priority>3</priority>
<example><![CDATA[protected static function foo() : void // VIOLATION
{
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.maintanability.EmptyStatementRule" message="This statement is empty">
<description/>
<priority>5</priority>
<example><![CDATA[protected function foo() : void
{
var i : int = 0;
; // VIOLATION
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.naming.TooShortVariableRule" message="This variable name is too short ({0} characters minimum, but {1} actually)">
<description>Detects when a field, local, or parameter has a very short name.</description>
<priority>5</priority>
<properties>
<property name="minimum">
<value>3</value>
</property>
</properties>
<example><![CDATA[public class Something
{
private var q : int = 15; // VIOLATION - Field
public function foo( as : String ) : void // VIOLATION - Formal
{
var r : int = 20 + q; // VIOLATION - Local
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.naming.PackageCaseRule" message="A package name should be lower case ({0})">
<description>Detects when a package definition contains upper case characters.</description>
<priority>3</priority>
<example><![CDATA[
package com.MyCompany // VIOLATION <- should be lower case name
{
public class SomeClass
{
}
}
]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.naming.VariableNameEndingWithNumericRule" message="Using digits at the end of a symbol does not help understanging the meaning of it. ({0})">
<description/>
<priority>3</priority>
<example><![CDATA[
public class SomeClass
{
public var correctField1 : int = 0; // VIOLATION <- numeric suffix is forbidden
}
]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.naming.PropertyHiddenByLocalVariableRule" message="A class property is hidden by this local variable ({0})">
<description/>
<priority>3</priority>
<example><![CDATA[public class SomeClass
{
public var myField : int = 0;
public function foo() : void
{
var myField : int = 9; // VIOLATION
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.naming.UncorrectClassCase" message="A class name must start by a majuscule character">
<description/>
<priority>3</priority>
<example><![CDATA[public class foo // VIOLATION
{
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.naming.WronglyNamedVariableRule" message="This variable ({0}) seems to be incorrectly named. Let your creativity flow">
<description/>
<priority>3</priority>
<example><![CDATA[
public class SomeClass
{
public var myField : int = 0; // VIOLATION <- my prefix is forbidden
public function tmpFoo() : void // VIOLATION <- tmp prefix is forbidden
{
var tempFoo : int = 9; // VIOLATION <- temp prefix is forbidden
}
}
]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.parsley.InaccessibleMetaDataRule" message="Parsley metadata should not be placed on inaccessible members.">
<description>Parsley can only process metadata that is placed onto public members.</description>
<priority>1</priority>
<example><![CDATA[[MessageHandler]
private function doSomething() : void // VIOLATION
{
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.parsley.MismatchedManagedEventRule" message="Managed events should have matching [Event] metadata">
<description>Each managed event should have matching [Event] metadata.</description>
<priority>1</priority>
<example><![CDATA[[Event(name="message", type="my.package.MyEvemt")]
[ManagedEvents(names="messag")] // VIOLATION
public class MyClass
{
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.parsley.MessageInterceptorSignatureRule" message="The signature of the message interceptor {0} is not correct. {1}.">
<description/>
<priority>1</priority>
<example><![CDATA[
[MessageInterceptor(type="a.b.MyMessage")]
public function messageInterceptor( processor : MessageProcessor ) : void
{
processor.proceed();
}
[MessageInterceptor(type="a.b.MyMessage")]
public function messageInterceptor() : void // VIOLATION
{
}
[MessageInterceptor(type="a.b.MyMessage")]
public function messageInterceptor( type : MyMessage ) : void // VIOLATION
{
type.something();
}
[MessageInterceptor(type="a.b.MyMessage")]
public function messageInterceptor( processor : MessageProcessor, type : MyMessage ) : void // VIOLATION
{
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.parsley.MisplacedMetaDataRule" message="This metadata {0} is misplaced">
<description/>
<priority>1</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.parsley.RedundantMessageHandlerTypeAttributeRule" message="This type metadata argument is redundant with the handler argument type">
<description/>
<priority>3</priority>
<example><![CDATA[
[MessageHandler(type="a.b.MyMessage")] // VIOLATION
public function doSomething( message : MyMessage ) : void
{
message.toString();
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.parsley.RedundantMethodAttributeRule" message="This method metadata argument is redundant with the handler name">
<description/>
<priority>3</priority>
<example><![CDATA[
[MessageHandler(method="doSomething")] // VIOLATION
public function doSomething( message : MyMessage ) : void
{
message.toString();
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.parsley.UnknownMetaDataAttributeRule" message="This metadata attribute {0} is unknown">
<description/>
<priority>1</priority>
<example><![CDATA[
[AsyncInit(x="y")] // VIOLATION
public class UnknownMetaDataAttribute
{
[Inject(x="y")] // VIOLATION
public var inject;
[MessageHandler(x="y")] // VIOLATION
public function messageHandler() : void
{
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.performance.DynamicFiltersUsedInPopup" message="A popup should not use dynamic filters">
<description>Prefer using embed filters in assets</description>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.performance.CyclomaticComplexityRule" message="This method is too complex. Maximum complexity is {0}, but its cyclomatic complexity was {1}">
<description/>
<priority>3</priority>
<properties>
<property name="maximum">
<value>10</value>
</property>
</properties>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.performance.HeavyConstructorRule" message="Constructor must be as lightweight as possible. No control statement allowed, whereas a cyclomatic complexe of {0} has been detected">
<description>The Just-In-Time compiler does not compile constructors. Make them as lightweight as possible, or move the complexity of the code to a method called by the constructor. Then the complexity will be compiled by the JIT.</description>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.performance.CreationPolicySetToAllRule" message="creationPolicy to ALL impacts the performance significantly">
<description/>
<priority>1</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.performance.BindableClassRule" message="Globally bindable classes can lead to unexpected behaviour especially when you have a setter to a property, and hits the performance of the application">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.performance.AvoidInstanciationInLoopRule" message="Instanciating a variable in a loop can be expensive">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.performance.DeeplyNestedIfRule" message="Nested if statements are not a good design">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.performance.RecursiveStyleManagerRule" message="Detect calls to the StyleManager that don’t pass “false” as the second parameter">
<description>A recursive style manager call can be a very expensive operation, causing parts of the UI to flicker visibly. Instead it is preferable to defer the creation of parts of the UI that depend on a runtime CSS SWF until after the SWF has been loaded. In this case a recursive call is not required.</description>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.sizing.TooManyFunctionRule" message="Too many methods detected ({0} maximum, but {1} actually)">
<description>A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.</description>
<priority>3</priority>
<properties>
<property name="maximum">
<value>15</value>
</property>
</properties>
<example><![CDATA[public class Foo
{
public function doWork() : void {}
public function doMoreWork() : void {}
public function doWorkAgain() : void {}
// [... more more public methods ...]
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.sizing.TooLongFunctionRule" message="This function is far too long ({0} maximum, but {1} actually)">
<description>Violations of this rule usually indicate that the method has too much responsibility. Try to reduce the method size by creating helper methods and removing any copy/pasted code.</description>
<priority>3</priority>
<properties>
<property name="maximum">
<value>20</value>
</property>
</properties>
<example><![CDATA[public class Foo
{
public function doSomething() : void
{
System.out.println("Hello world!");
System.out.println("Hello world!");
// 98 copies omitted for brevity.
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.sizing.TooLongSwitchCaseRule" message="Long switch case detected ({0} lines maximum, but {1} actually)">
<description>A switch case statement should be either empty, or contain a break, or call another method.</description>
<priority>3</priority>
<properties>
<property name="maximum">
<value>3</value>
</property>
</properties>
<example><![CDATA[public class Bar
{
public function foo() : void
{
var i : int = 4;
switch( i )
{
case 1:
handleFirstCase();
break;
case 2: // VIOLATION
googleResquest.url = "";
handleSecondCaseFirstPart();
handleSecondCaseSecondPart();
break;
}
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.sizing.TooManyParametersRule" message="Long parameter list detected ({0} maximum, but {1} actually)">
<description>Long parameter lists can indicate that a new object should be created to wrap the numerous parameters. Basically, try to group the parameters together.</description>
<priority>3</priority>
<properties>
<property name="maximum">
<value>4</value>
</property>
</properties>
<example><![CDATA[public class Foo
{
public function addData( p0 : int, p1 : int, p2 : int, p3 : int, p4 : int, p5 : int,
p6 : int, p7 : int, p8 : int, p9 : int, p10 : int ) : void
{
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.sizing.TooManyPublicRule" message="Too many public fields or functions detected ({0} maximum, but {1} actually)">
<description>A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.</description>
<priority>3</priority>
<properties>
<property name="maximum">
<value>10</value>
</property>
</properties>
<example><![CDATA[public class Foo
{
public var value : String;
public var something : Bar;
public var variable : Variable;
// [... more more public attributes ...]
public function doWork() : void {}
public function doMoreWork() : void {}
public function doWorkAgain() : void {}
// [... more more public methods ...]
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.sizing.TooManyFieldsRule" message="Too many field detected ({0} maximum, but {1} actually)">
<description>Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zipcode fields could instead have one Address field.</description>
<priority>3</priority>
<properties>
<property name="maximum">
<value>10</value>
</property>
</properties>
<example><![CDATA[public class Person
{
private var one : String;
private var two : int;
private var three : int;
[... many more public fields ...]
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.sizing.TooManyFieldInVORule" message="Too many field detected ({0} maximum, but {1} actually)">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.style.ConstructorNonEmptyReturnTypeRule" message="A constructor should not have a return type">
<description>Even if this is syntactically correct, there should not be a return type for a constructor.</description>
<priority>5</priority>
<example><![CDATA[public class VoidConstructor
{
public function VoidConstructor() : void // VIOLATION
{
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.style.OverLongLineRule" message="Too long line ({0} maximum, but {1} actually)">
<description/>
<priority>5</priority>
<properties>
<property name="maximum">
<value>200</value>
</property>
</properties>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.style.ImportFromSamePackageRule" message="Imports from the same package are not necessary">
<description/>
<priority>5</priority>
<example><![CDATA[package com.adobe.ac
{
import com.adobe.ac.MyModel; // VIOLATION HERE
public class BigModel
{
public var model : MyModel = null;
}
}]]></example>
</rule>
<!-- <rule since="" class="com.adobe.ac.pmd.rules.style.CopyrightMissingRule" message="The copyright header is missing in this file">
<description/>
<priority>5</priority>
</rule> -->
<rule since="" class="com.adobe.ac.pmd.rules.style.BadFormatLoggerRule" message="The logger is not correctly formatted because {0}">
<description/>
<priority>5</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.switchrules.SwitchStatementsShouldHaveDefaultRule" message="A switch statement does not contain a default statement">
<description>Switch statements should have a default label in order to detect corner cases.</description>
<priority>1</priority>
<example><![CDATA[public class Foo
{
public funciton bar() : void
{
var x : int = 2;
switch (x)
{
case 2: var j : int = 8;
}
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.switchrules.NestedSwitchRule" message="Switch must not be nested">
<description>As a general practice, switch statement should not be used. Prefer using inheritance. It is even harder to read when switch statements are nested.</description>
<priority>3</priority>
<example><![CDATA[public function foo( a : Number, b : Number ) : void
{
switch( a )
{
case 1:
break;
case 2:
switch ( b )
{
case 3 :
break;
case 4 :
break;
}
break;
}
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.switchrules.TooFewBrancheInSwitchStatementRule" message="There are too few branches in this switch statement ({0} minimum, but {1} actual)">
<description>Switch statements are designed for complex branches, and allow branches to share treatment. Using a switch for only 2 branches is ill advised, as switches are not as easy to understand as if. In this case, it's most likely is a good idea to use a if statement</description>
<priority>5</priority>
<properties>
<property name="minimum">
<value>3</value>
</property>
</properties>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.switchrules.IdenticalSwitchCasesRule" message="Two switch cases should not be identical">
<description/>
<priority>1</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.flexunit.EmptyUnitTest" message="A test should contain at least one assertion">
<description/>
<priority>3</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.unused.UnusedParameterRule" message="This parameter ({0}) of this function is not used">
<description/>
<priority>5</priority>
<example><![CDATA[public function foo( param1 : Number, param2 : Number, param3 : Number, param4 : Number, param5 : Number ) : void // 4 violations
{
var i : int = param1;
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.unused.UnusedLocalVariableRule" message="This variable ({0}) is not used">
<description/>
<priority>3</priority>
<example><![CDATA[public function foo() : void
{
var i : int = 0;// 1 violation
}]]></example>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.unused.UnusedPrivateMethodRule" message="This private method ({0}) does not seem to be used">
<description/>
<priority>1</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.unused.UnusedFieldRule" message="This private attribute ({0}) does not seem to be used">
<description/>
<priority>1</priority>
</rule>
<rule since="" class="com.adobe.ac.pmd.rules.unused.EmptyPrivateMethodRule" message="This private method ({0}) is used but its content is empty">
<description/>
<priority>1</priority>
</rule>
</ruleset>