
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
62 lines
1.0 KiB
Plaintext
62 lines
1.0 KiB
Plaintext
== 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[]
|