Avoid clone event not overiden in a custom event | CAST Appmarq

Avoid clone event not overiden in a custom event

CRITICAL

Rule Definition
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.

Remediation
Always override clone() method in custom event class.

Violation Code Sample
public class FirstCustomEvent   // VIOLATION - clone method is missing
{
   public var lala : String;
   
   public function FirstCustomEvent()
   {         
   }
}

Reference
http://opensource.adobe.com/wiki/display/flexpmd/FlexPMD

Related Technologies

Health Factor

  Total Quality Index


Technical Criterion
Programming Practices - Unexpected Behavior

About CAST Appmarq

CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.

Benchmark Statistics

Global Compliance

100.00%

Total Violations
1
Total Opportunities
26,492
Average Violations / App.
0.17
The compliance score represents 1 minus the ratio between the number of times a rule has been violated compared to the number of opportunities in a set of applications that the rule could have been violated.

Industry Insights

Insurance

99.17%

IT & Business Consulting

94.12%

Financial Services

99.79%