Avoid MXML component with more than 2 public variables | CAST Appmarq

Avoid MXML component with more than 2 public variables

CRITICAL

Rule Definition
Reports MXML components with more than 2 public variables

Remediation
Have only one entry point into MXML component.

Violation Code Sample
<mx:Script>
      <![CDATA[
      
      public var firstPublicVariable:int = 1;
      private var _secondPublicVariable:int = 2;
      public var thirdPublicVariable:int = 3;
        
      public function get secondPublicVariable() : int {
         return _secondPublicVariable;
      }
      
      public function set secondPublicVariable(anint: int) : int {
         _secondPublicVariable = anint;
      }

      //...       
        

        ]]>
   </mx:Script>
Fixed Code Sample
<mx:Script>
      <![CDATA[
      
      private var firstPublicVariable:int = 1;
      private var _secondPublicVariable:int = 2;
      public var thirdPublicVariable:int = 3;
        
      public function get secondPublicVariable() : int {
         return _secondPublicVariable;
      }
      
      //...       
        

        ]]>
   </mx:Script>

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

Related Technologies

Health Factor

  Total Quality Index


Technical Criterion
Secure Coding - Encapsulation

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

98.98%

Total Violations
39
Total Opportunities
3,817
Average Violations / App.
7.80
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

59.14%

Financial Services

95.88%

Don't Know

100.00%