Make methods static. #1555
Fixes `MethodMayBeStatic` inspection violations. Description: >Reports any methods which may safely be made static. A method may be static if it is not synchronized, it does not reference any of its class' non static methods and non static fields and is not overridden in a sub class.
This commit is contained in:
parent
c0a69490d7
commit
1ab08ad4ab
|
|
@ -37,7 +37,7 @@ public class ConfigurationBuilder extends BaseCheckTestSupport {
|
|||
listFiles(files, ROOT, "java");
|
||||
}
|
||||
|
||||
private Configuration getConfigurationFromXML(String aConfigName,
|
||||
private static Configuration getConfigurationFromXML(String aConfigName,
|
||||
Properties aProps) throws CheckstyleException {
|
||||
try {
|
||||
return ConfigurationLoader.loadConfiguration(aConfigName,
|
||||
|
|
|
|||
|
|
@ -51,12 +51,12 @@ import com.puppycrawl.tools.checkstyle.api.Configuration;
|
|||
@PrepareForTest({ ConfigurationLoader.class, ConfigurationLoaderTest.class })
|
||||
public class ConfigurationLoaderTest {
|
||||
|
||||
private Configuration loadConfiguration(String name)
|
||||
private static Configuration loadConfiguration(String name)
|
||||
throws CheckstyleException {
|
||||
return loadConfiguration(name, new Properties());
|
||||
}
|
||||
|
||||
private Configuration loadConfiguration(
|
||||
private static Configuration loadConfiguration(
|
||||
String name, Properties props) throws CheckstyleException {
|
||||
final String fName =
|
||||
"src/test/resources/com/puppycrawl/tools/checkstyle/configs/" + name;
|
||||
|
|
@ -213,7 +213,7 @@ public class ConfigurationLoaderTest {
|
|||
.containsKey("name.invalidPattern"));
|
||||
}
|
||||
|
||||
private void verifyConfigNode(
|
||||
private static void verifyConfigNode(
|
||||
DefaultConfiguration config, String name, int childrenLength,
|
||||
Properties atts) throws Exception {
|
||||
assertEquals("name.", name, config.getName());
|
||||
|
|
@ -298,7 +298,7 @@ public class ConfigurationLoaderTest {
|
|||
}
|
||||
}
|
||||
|
||||
private Properties initProperties() {
|
||||
private static Properties initProperties() {
|
||||
final Properties props = new Properties();
|
||||
props.put("a", "A");
|
||||
props.put("b", "B");
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class PackageNamesLoaderTest {
|
|||
validatePackageNames(packageNames);
|
||||
}
|
||||
|
||||
private void validatePackageNames(Set<String> pkgNames) {
|
||||
private static void validatePackageNames(Set<String> pkgNames) {
|
||||
final String[] checkstylePackages = {
|
||||
"com.puppycrawl.tools.checkstyle.",
|
||||
"com.puppycrawl.tools.checkstyle.checks.",
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ public class DetailASTTest {
|
|||
}
|
||||
}
|
||||
|
||||
private void checkFile(String filename) throws Exception {
|
||||
private static void checkFile(String filename) throws Exception {
|
||||
final FileText text = new FileText(new File(filename),
|
||||
System.getProperty("file.encoding", "UTF-8"));
|
||||
final FileContents contents = new FileContents(text);
|
||||
|
|
@ -139,7 +139,7 @@ public class DetailASTTest {
|
|||
}
|
||||
}
|
||||
|
||||
private void checkTree(final DetailAST node,
|
||||
private static void checkTree(final DetailAST node,
|
||||
final DetailAST parent,
|
||||
final DetailAST prev,
|
||||
final String filename,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.junit.Test;
|
|||
|
||||
public class FullIdentTest {
|
||||
|
||||
public void testToString() {
|
||||
public static void testToString() {
|
||||
DetailAST ast = new DetailAST();
|
||||
ast.setType(TokenTypes.LITERAL_NEW);
|
||||
ast.setColumnNo(14);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public class UniquePropertiesCheckTest extends BaseFileSetCheckTestSupport {
|
|||
* @param file to be opened
|
||||
* @return detail message of {@link FileNotFoundException}
|
||||
*/
|
||||
private String getFileNotFoundDetail(File file) throws Exception {
|
||||
private static String getFileNotFoundDetail(File file) throws Exception {
|
||||
// Create exception to know detail message we should wait in
|
||||
// LocalisedMessage
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public class FileTabCharacterCheckTest
|
|||
* Creates a configuration that is functionally close to that in the docs.
|
||||
* @param verbose verbose mode
|
||||
*/
|
||||
private DefaultConfiguration createConfig(boolean verbose) {
|
||||
private static DefaultConfiguration createConfig(boolean verbose) {
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(FileTabCharacterCheck.class);
|
||||
checkConfig.addAttribute("eachLine", Boolean.toString(verbose));
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class CompareTreesWithComments extends Check {
|
|||
Assert.assertTrue(isAstEquals(expectedTree, aRootAST));
|
||||
}
|
||||
|
||||
private boolean isAstEquals(DetailAST expected, DetailAST actual) {
|
||||
private static boolean isAstEquals(DetailAST expected, DetailAST actual) {
|
||||
boolean result = false;
|
||||
if (expected == actual) {
|
||||
result = true;
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public class SuppressWarningsFilterTest
|
|||
return checker;
|
||||
}
|
||||
|
||||
private String[] removeSuppressed(String[] from, String[] remove) {
|
||||
private static String[] removeSuppressed(String[] from, String[] remove) {
|
||||
final Collection<String> coll =
|
||||
Lists.newArrayList(Arrays.asList(from));
|
||||
coll.removeAll(Arrays.asList(remove));
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ public class SuppressWithNearbyCommentFilterTest
|
|||
return checker;
|
||||
}
|
||||
|
||||
private String[] removeSuppressed(String[] from, String[] remove) {
|
||||
private static String[] removeSuppressed(String[] from, String[] remove) {
|
||||
final Collection<String> coll =
|
||||
Lists.newArrayList(Arrays.asList(from));
|
||||
coll.removeAll(Arrays.asList(remove));
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ public class SuppressionCommentFilterTest
|
|||
return checker;
|
||||
}
|
||||
|
||||
private String[] removeSuppressed(String[] from, String[] remove) {
|
||||
private static String[] removeSuppressed(String[] from, String[] remove) {
|
||||
final Collection<String> coll =
|
||||
Lists.newArrayList(Arrays.asList(from));
|
||||
coll.removeAll(Arrays.asList(remove));
|
||||
|
|
|
|||
Loading…
Reference in New Issue