== Why is this an issue?

In ActionScript 3, constructor code is always interpreted rather than compiled by the JIT at runtime, which is why the body of a constructor should be as lightweight as possible. As soon as a constructor contains branches ("if", "for", "switch", ...) an issue is logged.


=== Noncompliant code example

[source,flex]
----
public class Foo
{
  public function Foo()
  {
    if (condition) {  // Noncompliant
      // ...
    }
  }
} 
----


=== Compliant solution

[source,flex]
----
public class Foo
{
  public function Foo()
  {
    init()
  }

  private function init():void 
  {
    if (condition) { 
      // ...
    }
  }
} 
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Extract the content of this "XXX" constructor into a dedicated function


'''
== Comments And Links
(visible only on this page)

=== on 31 Oct 2013, 16:05:47 Freddy Mallet wrote:
Is implemented by \http://jira.codehaus.org/browse/SONARPLUGINS-3227 for Flex

endif::env-github,rspecator-view[]
