rspec/rules/S1447/flex/rule.adoc

62 lines
1.0 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
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
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,flex]
2021-04-28 16:49:39 +02:00
----
public class Foo
{
public function Foo()
{
if (condition) { // Noncompliant
// ...
}
}
}
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,flex]
2021-04-28 16:49:39 +02:00
----
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[]