rspec/rules/S3239/comments-and-links.adoc

66 lines
1.4 KiB
Plaintext

=== on 7 Jul 2015, 13:38:24 Tamas Vajk wrote:
\[~ann.campbell.2] This rule should not be only about complete method or loop bodies. It can be partial as well:
----
public void AnyMethod()
{
CallSomeOtherMethod1();
CallSomeOtherMethod2();
CallSomeOtherMethod3();
if (someCondition)
{
CallSomeOtherMethod4();
CallSomeOtherMethod5();
}
}
----
can be converted to
----
public void AnyMethod()
{
CallSomeOtherMethod1();
CallSomeOtherMethod2();
CallSomeOtherMethod3();
if (!someCondition)
{
return;
}
CallSomeOtherMethod4();
CallSomeOtherMethod5();
}
----
If the last statement in a method or loop is an ``++if++`` we can do this transformation. (And as a consequence if the only statement in a method is an ``++if++``, we can also do it.)
=== on 8 Jul 2015, 14:22:14 Ann Campbell wrote:
see what you think now [~tamas.vajk]
=== on 20 Jul 2015, 11:47:59 Tamas Vajk wrote:
\[~ann.campbell.2] Should we add that the code block needs to contain at least two statements? (That's how R# works)
So:
----
public void MyMethod()
{
if (condition) //compliant, has only one statement inside
{
DoSomeThing();
}
}
public void MyMethod2()
{
if (condition) //noncompliant
{
DoSomeThing();
DoSomeThingElse();
}
}
----
=== on 20 Jul 2015, 13:56:09 Ann Campbell wrote:
I've added explicit text to that effect & beefed up the example [~tamas.vajk]