Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

squid:S2325 - "private" methods that dont access instance data should… #1048

Merged
merged 1 commit into from
Feb 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public Boolean convert(String value, Class<? extends Boolean> type) {
throw new ConversionException(new ConversionMessage(INVALID_MESSAGE_KEY, value));
}

private boolean matches(Set<String> words, String value) {
private static boolean matches(Set<String> words, String value) {
return words.contains(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public ExceptionRecorder<Result> findByException(Exception e) {
return hasExceptionCause(e) ? findByException((Exception) e.getCause()) : null;
}

private boolean hasExceptionCause(Exception e) {
private static boolean hasExceptionCause(Exception e) {
return e.getCause() != null && e.getCause() instanceof Exception;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ private String uriRelativeToContextRoot(HttpServletRequest request) {
return removeQueryStringAndJSessionId(uri);
}

private String removeQueryStringAndJSessionId(String uri) {
private static String removeQueryStringAndJSessionId(String uri) {
if (uri.contains("?") || uri.contains(";")) {
return uri.replaceAll("[\\?;].+", "");
}
return uri;
}

private boolean isAFile(URL resourceUrl) {
private static boolean isAFile(URL resourceUrl) {
return !resourceUrl.toString().endsWith("/");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ public String run() {
/**
* Find environment name using {@code VRAPTOR_ENV} from system environment.
*/
private String fromSystemEnv() {
private static String fromSystemEnv() {
return System.getenv("VRAPTOR_ENV");
}

/**
* Find environment name using {@code br.com.caelum.vraptor.environment} from system property. To define this
* you can start the application server using {@code -Dbr.com.caelum.vraptor.environment=DEVELOPMENT}.
*/
private String fromSystemProperty() {
private static String fromSystemProperty() {
return System.getProperty(ENVIRONMENT_PROPERTY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private void addParametersInfo(Method method) {
}
}

private String[] sanitize(String[] parameters) {
private static String[] sanitize(String[] parameters) {
String[] sanitized = new String[parameters.length];
for (int i = 0; i < parameters.length; i++) {
sanitized[i] = parameters[i].replaceAll("(\\:.*|\\*)$", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ protected String[] getUris(Method javaMethod){
return new String[0];
}
return (String[]) reflectionProvider.invoke(method, "value");
}
}

protected void fixURIs(Class<?> type, String[] uris) {
String prefix = extractPrefix(type);
Expand Down Expand Up @@ -202,7 +202,7 @@ protected String extractPrefix(Class<?> type) {
}
}

private String fixLeadingSlash(String uri) {
private static String fixLeadingSlash(String uri) {
if (!uri.startsWith("/")) {
return "/" + uri;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void deserializes(@Observes InterceptorsReady event, HttpServletRequest r
}
}

private String mime(String contentType) {
private static String mime(String contentType) {
if (contentType.contains(";")) {
return contentType.split(";")[0];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void write(HttpServletResponse response) throws IOException {
}
}

private File checkFile(File file) throws FileNotFoundException {
private static File checkFile(File file) throws FileNotFoundException {
if (!file.exists()) {
throw new FileNotFoundException("File " + file.getName() + " doesn't exists");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private Deserializer subpathDeserializerForPlus(String contentType, Container co
return null;
}

private String removeChar(String type, String by) {
private static String removeChar(String type, String by) {
return type.substring(type.lastIndexOf(by)+1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public Object[] deserialize(InputStream inputStream, ControllerMethod method) {
return values;
}

private Type fallbackTo(Type parameterizedType, Class<?> type) {
private static Type fallbackTo(Type parameterizedType, Class<?> type) {
if (parameterizedType instanceof TypeVariable) return type;
return parameterizedType;
}
Expand All @@ -174,7 +174,7 @@ private String getRequestCharset() {
return charset.split(",")[0];
}

private boolean isWithoutRoot(Parameter[] parameters, JsonObject root) {
private static boolean isWithoutRoot(Parameter[] parameters, JsonObject root) {
for (Parameter parameter : parameters) {
if (root.get(parameter.getName()) != null)
return false;
Expand All @@ -192,7 +192,7 @@ protected Class<?>[] getTypes(ControllerMethod method) {
return parameterTypes;
}

private Class<?>[] parseGenericParameters(Class<?>[] parameterTypes,
private static Class<?>[] parseGenericParameters(Class<?>[] parameterTypes,
Type genericType) {
Class<?> type = (Class<?>) getGenericType(genericType);
for (int i = 0; i < parameterTypes.length; i++) {
Expand All @@ -203,7 +203,7 @@ private Class<?>[] parseGenericParameters(Class<?>[] parameterTypes,
return parameterTypes;
}

private Type getGenericSuperClass(ControllerMethod method) {
private static Type getGenericSuperClass(ControllerMethod method) {
Type genericType = method.getController().getType().getGenericSuperclass();
if (genericType instanceof ParameterizedType) {
return genericType;
Expand All @@ -212,7 +212,7 @@ private Type getGenericSuperClass(ControllerMethod method) {
return null;
}

private Type getGenericType(Type type) {
private static Type getGenericType(Type type) {
ParameterizedType paramType = (ParameterizedType) type;
return paramType.getActualTypeArguments()[0];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public boolean shouldSerializeMember(Class definedIn, String fieldName) {
return should;
}

private boolean isCompatiblePath(Entry<String, Class<?>> path, Class definedIn, String fieldName) {
private static boolean isCompatiblePath(Entry<String, Class<?>> path, Class definedIn, String fieldName) {
return path.getValue().equals(definedIn) && (path.getKey().equals(fieldName) || path.getKey().endsWith("." + fieldName));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public XStream getConfiguredXStream(Method javaMethod, Class<?>[] types) {
return xStream;
}

private void chooseParam(Class<?>[] types, Object[] params, Object deserialized) {
private static void chooseParam(Class<?>[] types, Object[] params, Object deserialized) {
for (int i = 0; i < types.length; i++) {
if (types[i].isInstance(deserialized)) {
params[i] = deserialized;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private MimeType convertToMimeType(String string) {
return new MimeType(string, 1);
}

private double extractQualifier(String string) {
private static double extractQualifier(String string) {
double qualifier = DEFAULT_QUALIFIER_VALUE;
if (string.contains("q=")) {
Matcher matcher = Pattern.compile("\\s*q=(.+)\\s*").matcher(string);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected String extractControllerFromName(String baseName) {
return baseName;
}

private String lowerFirstCharacter(String baseName) {
private static String lowerFirstCharacter(String baseName) {
return baseName.toLowerCase().substring(0, 1) + baseName.substring(1, baseName.length());
}
}