Add Builder pattern check
Summary: Add the builder pattern check to the MissingStaticMethodInNonInstantiatableClass rule Test Plan: run tests Reviewers: jmsotuyo Reviewed By: jmsotuyo Maniphest Tasks: T1440 Differential Revision: http://ph.monits.com/D13295
This commit is contained in:
@ -843,6 +843,21 @@ A class that has private constructors and does not have any static methods or fi
|
|||||||
]
|
]
|
||||||
) > 0]
|
) > 0]
|
||||||
) = 0
|
) = 0
|
||||||
|
and
|
||||||
|
count(//ClassOrInterfaceDeclaration
|
||||||
|
[@Nested='true']
|
||||||
|
[@Static='true']
|
||||||
|
[@Public='true']
|
||||||
|
[.//MethodDeclaration
|
||||||
|
[@Public='true']
|
||||||
|
[.//ReturnStatement//AllocationExpression
|
||||||
|
[ClassOrInterfaceType
|
||||||
|
[@Image = //ClassOrInterfaceDeclaration/@Image]
|
||||||
|
]
|
||||||
|
[./Arguments//PrimaryPrefix/@ThisModifier='true']
|
||||||
|
]
|
||||||
|
]
|
||||||
|
) = 0
|
||||||
]
|
]
|
||||||
]]>
|
]]>
|
||||||
</value>
|
</value>
|
||||||
|
@ -177,6 +177,38 @@ public class AccountSelectionSubForm extends Form implements WidgetEventListener
|
|||||||
{
|
{
|
||||||
super( parent, null );
|
super( parent, null );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
|
||||||
|
<test-code>
|
||||||
|
<description>Check Builder pattern</description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public final class BacklogElementParameters {
|
||||||
|
private final Long backlogId;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private BacklogElementParameters(final BacklogElementParameters.Builder builder) {
|
||||||
|
this.backlogId = builder.backlogId;
|
||||||
|
this.name = builder.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
public Builder backlogId(final Long backlogId) {
|
||||||
|
this.backlogId = backlogId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder name(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BacklogElementParameters build() {
|
||||||
|
return new BacklogElementParameters(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
Reference in New Issue
Block a user