Skip to content

Commit

Permalink
CheckStyle: Fix name violations
Browse files Browse the repository at this point in the history
  • Loading branch information
Pieter12345 committed Jun 12, 2018
1 parent fc08e99 commit 065ca39
Show file tree
Hide file tree
Showing 125 changed files with 1,431 additions and 1,397 deletions.
30 changes: 15 additions & 15 deletions src/main/java/com/laytonsmith/PureUtilities/ArgumentParser.java
Expand Up @@ -949,17 +949,17 @@ static List<String> lex(String args) {
//First, we have to tokenize the strings. Since we can have quoted arguments, we can't simply split on spaces. //First, we have to tokenize the strings. Since we can have quoted arguments, we can't simply split on spaces.
List<String> arguments = new ArrayList<String>(); List<String> arguments = new ArrayList<String>();
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
boolean state_in_single_quote = false; boolean stateInSingleQuote = false;
boolean state_in_double_quote = false; boolean stateInDoubleQuote = false;
for(int i = 0; i < args.length(); i++) { for(int i = 0; i < args.length(); i++) {
Character c0 = args.charAt(i); Character c0 = args.charAt(i);
Character c1 = i + 1 < args.length() ? args.charAt(i + 1) : null; Character c1 = i + 1 < args.length() ? args.charAt(i + 1) : null;


if(c0 == '\\') { if(c0 == '\\') {
if(c1 == '\'' && state_in_single_quote if(c1 == '\'' && stateInSingleQuote
|| c1 == '"' && state_in_double_quote || c1 == '"' && stateInDoubleQuote
|| c1 == ' ' && !state_in_double_quote && !state_in_single_quote || c1 == ' ' && !stateInDoubleQuote && !stateInSingleQuote
|| c1 == '\\' && (state_in_double_quote || state_in_single_quote)) { || c1 == '\\' && (stateInDoubleQuote || stateInSingleQuote)) {
//We are escaping the next character. Add it to the buffer instead, and //We are escaping the next character. Add it to the buffer instead, and
//skip ahead two //skip ahead two
buf.append(c1); buf.append(c1);
Expand All @@ -970,7 +970,7 @@ static List<String> lex(String args) {
} }


if(c0 == ' ') { if(c0 == ' ') {
if(!state_in_double_quote && !state_in_single_quote) { if(!stateInDoubleQuote && !stateInSingleQuote) {
//argument split //argument split
if(buf.length() != 0) { if(buf.length() != 0) {
arguments.add(buf.toString()); arguments.add(buf.toString());
Expand All @@ -979,31 +979,31 @@ static List<String> lex(String args) {
continue; continue;
} }
} }
if(c0 == '\'' && !state_in_double_quote) { if(c0 == '\'' && !stateInDoubleQuote) {
if(state_in_single_quote) { if(stateInSingleQuote) {
state_in_single_quote = false; stateInSingleQuote = false;
arguments.add(buf.toString()); arguments.add(buf.toString());
buf = new StringBuilder(); buf = new StringBuilder();
} else { } else {
if(buf.length() != 0) { if(buf.length() != 0) {
arguments.add(buf.toString()); arguments.add(buf.toString());
buf = new StringBuilder(); buf = new StringBuilder();
} }
state_in_single_quote = true; stateInSingleQuote = true;
} }
continue; continue;
} }
if(c0 == '"' && !state_in_single_quote) { if(c0 == '"' && !stateInSingleQuote) {
if(state_in_double_quote) { if(stateInDoubleQuote) {
state_in_double_quote = false; stateInDoubleQuote = false;
arguments.add(buf.toString()); arguments.add(buf.toString());
buf = new StringBuilder(); buf = new StringBuilder();
} else { } else {
if(buf.length() != 0) { if(buf.length() != 0) {
arguments.add(buf.toString()); arguments.add(buf.toString());
buf = new StringBuilder(); buf = new StringBuilder();
} }
state_in_double_quote = true; stateInDoubleQuote = true;
} }
continue; continue;
} }
Expand Down
Expand Up @@ -63,36 +63,36 @@ public ClassDiscoveryURLCache(URL url, ProgressIterator progress) {
* @throws java.lang.ClassNotFoundException * @throws java.lang.ClassNotFoundException
*/ */
public ClassDiscoveryURLCache(URL url, InputStream descriptor) throws IOException, ClassNotFoundException { public ClassDiscoveryURLCache(URL url, InputStream descriptor) throws IOException, ClassNotFoundException {
List<ClassMirror<?>> _list; List<ClassMirror<?>> list;
ObjectInputStream ois = new ObjectInputStream(descriptor); ObjectInputStream ois = new ObjectInputStream(descriptor);
try { try {
_list = (List<ClassMirror<?>>) ois.readObject(); list = (List<ClassMirror<?>>) ois.readObject();
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
if(url != null) { if(url != null) {
//We can recover from this one, but it won't be instant. //We can recover from this one, but it won't be instant.
_list = new ClassDiscoveryURLCache(url).list; list = new ClassDiscoveryURLCache(url).list;
} else { } else {
throw ex; throw ex;
} }
} }
ois.close(); ois.close();


for(ClassMirror m : _list) { for(ClassMirror m : list) {
ReflectionUtils.set(ClassMirror.class, m, "originalURL", url); ReflectionUtils.set(ClassMirror.class, m, "originalURL", url);
} }


this.list = _list; this.list = list;
} }


public void writeDescriptor(OutputStream out) throws IOException { public void writeDescriptor(OutputStream out) throws IOException {
ObjectOutputStream oos = new ObjectOutputStream(out); ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(list); oos.writeObject(this.list);
oos.close(); oos.close();
} }


@Override @Override
public String toString() { public String toString() {
return "[" + ClassDiscoveryURLCache.class.getSimpleName() + ": " + list.size() + "]"; return "[" + ClassDiscoveryURLCache.class.getSimpleName() + ": " + this.list.size() + "]";
} }


/** /**
Expand Down
Expand Up @@ -160,9 +160,9 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
for(Type type : Type.getArgumentTypes(desc)) { for(Type type : Type.getArgumentTypes(desc)) {
parameterMirrors.add(new ClassReferenceMirror(type.getDescriptor())); parameterMirrors.add(new ClassReferenceMirror(type.getDescriptor()));
} }
AbstractMethodMirror _methodMirror; AbstractMethodMirror methodMirror;
if(ConstructorMirror.INIT.equals(name)) { if(ConstructorMirror.INIT.equals(name)) {
_methodMirror = new ConstructorMirror( methodMirror = new ConstructorMirror(
classInfo.classReferenceMirror, classInfo.classReferenceMirror,
new ModifierMirror(ModifierMirror.Type.METHOD, access), new ModifierMirror(ModifierMirror.Type.METHOD, access),
new ClassReferenceMirror(Type.getReturnType(desc).getDescriptor()), new ClassReferenceMirror(Type.getReturnType(desc).getDescriptor()),
Expand All @@ -172,7 +172,7 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
(access & ACC_SYNTHETIC) == ACC_SYNTHETIC (access & ACC_SYNTHETIC) == ACC_SYNTHETIC
); );
} else { } else {
_methodMirror = new MethodMirror( methodMirror = new MethodMirror(
classInfo.classReferenceMirror, classInfo.classReferenceMirror,
new ModifierMirror(ModifierMirror.Type.METHOD, access), new ModifierMirror(ModifierMirror.Type.METHOD, access),
new ClassReferenceMirror(Type.getReturnType(desc).getDescriptor()), new ClassReferenceMirror(Type.getReturnType(desc).getDescriptor()),
Expand All @@ -182,22 +182,22 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
(access & ACC_SYNTHETIC) == ACC_SYNTHETIC (access & ACC_SYNTHETIC) == ACC_SYNTHETIC
); );
} }
final AbstractMethodMirror methodMirror = _methodMirror; final AbstractMethodMirror finalMethodMirror = methodMirror;
return new MethodVisitor(ASM5, super.visitMethod(access, name, desc, signature, exceptions)) { return new MethodVisitor(ASM5, super.visitMethod(access, name, desc, signature, exceptions)) {
@Override @Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) { public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
final AnnotationMirror annotationMirror = new AnnotationMirror(new ClassReferenceMirror<>(desc), visible); final AnnotationMirror annotationMirror = new AnnotationMirror(new ClassReferenceMirror<>(desc), visible);
return new AnnotationMirrorVisitor(super.visitAnnotation(desc, visible), annotationMirror) { return new AnnotationMirrorVisitor(super.visitAnnotation(desc, visible), annotationMirror) {
@Override @Override
public void visitEnd() { public void visitEnd() {
methodMirror.addAnnotation(annotationMirror); finalMethodMirror.addAnnotation(annotationMirror);
} }
}; };
} }


@Override @Override
public void visitEnd() { public void visitEnd() {
classInfo.methods.add(methodMirror); classInfo.methods.add(finalMethodMirror);
super.visitEnd(); super.visitEnd();
} }
}; };
Expand Down
Expand Up @@ -20,13 +20,13 @@ public class FieldMirror extends AbstractElementMirror {
*/ */
public FieldMirror(Field field) { public FieldMirror(Field field) {
super(field); super(field);
Object _value = null; Object value = null;
try { try {
_value = field.get(null); value = field.get(null);
} catch (IllegalArgumentException | IllegalAccessException ex) { } catch (IllegalArgumentException | IllegalAccessException ex) {
// //
} }
this.value = _value; this.value = value;
} }


/** /**
Expand Down
Expand Up @@ -19,7 +19,7 @@ public class ModifierMirror implements Serializable {
/** /**
* This is the canonical order of modifiers, used in the toString method. * This is the canonical order of modifiers, used in the toString method.
*/ */
private static final transient Object[] order = new Object[]{ private static final transient Object[] ORDER = new Object[]{
Modifier.PUBLIC, "public", Modifier.PUBLIC, "public",
Modifier.PRIVATE, "private", Modifier.PRIVATE, "private",
Modifier.PROTECTED, "protected", Modifier.PROTECTED, "protected",
Expand Down Expand Up @@ -246,9 +246,9 @@ public int getModifiers() {
@Override @Override
public String toString() { public String toString() {
List<String> build = new ArrayList<String>(); List<String> build = new ArrayList<String>();
for(int i = 0; i < order.length; i++) { for(int i = 0; i < ORDER.length; i++) {
int type = (Integer) order[i]; int type = (Integer) ORDER[i];
String name = (String) order[++i]; String name = (String) ORDER[++i];
if((modifiers & type) > 0) { if((modifiers & type) > 0) {
build.add(name); build.add(name);
} }
Expand Down
Expand Up @@ -51,11 +51,9 @@ public void write(int next) throws IOException {
c.setSystemOut(os); c.setSystemOut(os);
c.start(); c.start();
c.waitFor(); c.waitFor();
Byte[] Bytes = new Byte[output.size()];
byte[] bytes = new byte[output.size()]; byte[] bytes = new byte[output.size()];
Bytes = output.toArray(Bytes); for(int i = 0; i < output.size(); i++) {
for(int i = 0; i < Bytes.length; i++) { bytes[i] = output.get(i).byteValue();
bytes[i] = Bytes[i];
} }


return new String(bytes, "UTF-8"); return new String(bytes, "UTF-8");
Expand Down
Expand Up @@ -32,12 +32,12 @@ public static void checkForTypeInTypeofClasses() throws Exception {
for(ClassMirror<?> clazz : classes) { for(ClassMirror<?> clazz : classes) {
try { try {
// Make sure that TYPE has the same type as the typeof annotation // Make sure that TYPE has the same type as the typeof annotation
CClassType TYPE = (CClassType) ReflectionUtils.get(clazz.loadClass(), "TYPE"); CClassType type = (CClassType) ReflectionUtils.get(clazz.loadClass(), "TYPE");
if(TYPE == null) { if(type == null) {
errors.add("TYPE is null? " + clazz.getClassName()); errors.add("TYPE is null? " + clazz.getClassName());
continue; continue;
} }
if(!TYPE.val().equals(clazz.getAnnotation(typeof.class).getValue("value"))) { if(!type.val().equals(clazz.getAnnotation(typeof.class).getValue("value"))) {
errors.add(clazz.getClassName() + "'s TYPE value is different than the typeof annotation on it"); errors.add(clazz.getClassName() + "'s TYPE value is different than the typeof annotation on it");
} }
} catch (ReflectionUtils.ReflectionException ex) { } catch (ReflectionUtils.ReflectionException ex) {
Expand Down
Expand Up @@ -39,16 +39,16 @@
@SupportedSourceVersion(SourceVersion.RELEASE_7) @SupportedSourceVersion(SourceVersion.RELEASE_7)
public class CheckOverrides extends AbstractProcessor { public class CheckOverrides extends AbstractProcessor {


private static final boolean enabled = true; private static final boolean ENABLED = true;


private static Map<Class, Set<Method>> methods = null; private static Map<Class, Set<Method>> methods = null;
private static final Set<Class> interfacesWithMustUseOverride = new HashSet<>(); private static final Set<Class> INTERFACES_WITH_MUST_USE_OVERRIDE = new HashSet<>();
private static final Pattern METHOD_SIGNATURE = Pattern.compile("[a-zA-Z0-9_]+\\((.*)\\)"); private static final Pattern METHOD_SIGNATURE = Pattern.compile("[a-zA-Z0-9_]+\\((.*)\\)");
private static final Pattern CLASS_TEMPLATES = Pattern.compile("^.*?<(.*)>?$"); private static final Pattern CLASS_TEMPLATES = Pattern.compile("^.*?<(.*)>?$");


@Override @Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if(!enabled) { if(!ENABLED) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, "CheckOverrides processor is turned off!"); processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, "CheckOverrides processor is turned off!");
return false; return false;
} }
Expand All @@ -67,7 +67,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
"Only interfaces may be annotated with " + MustUseOverride.class.getName()); "Only interfaces may be annotated with " + MustUseOverride.class.getName());
} }
interfacesWithMustUseOverride.add(c); INTERFACES_WITH_MUST_USE_OVERRIDE.add(c);
} }
} }
for(Element element : roundEnv.getElementsAnnotatedWith(Override.class)) { for(Element element : roundEnv.getElementsAnnotatedWith(Override.class)) {
Expand Down Expand Up @@ -262,7 +262,7 @@ private static void getAllSupers(Class c, Set<Class> building, boolean first) {
} }
getAllSupers(c.getSuperclass(), building, false); getAllSupers(c.getSuperclass(), building, false);
for(Class cc : c.getInterfaces()) { for(Class cc : c.getInterfaces()) {
if(interfacesWithMustUseOverride.contains(cc)) { if(INTERFACES_WITH_MUST_USE_OVERRIDE.contains(cc)) {
building.add(cc); building.add(cc);
} }
} }
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/com/laytonsmith/PureUtilities/Common/FileUtil.java
Expand Up @@ -26,8 +26,8 @@ private FileUtil() {
public static final int OVERWRITE = 0; public static final int OVERWRITE = 0;
public static final int APPEND = 1; public static final int APPEND = 1;


private static final Map<String, Object> fileLocks = new HashMap<>(); private static final Map<String, Object> FILE_LOCKS = new HashMap<>();
private static final Map<String, Integer> fileLockCounter = new HashMap<>(); private static final Map<String, Integer> FILE_LOCK_COUNTER = new HashMap<>();


/** /**
* A more complicated mechanism is required to ensure global access across the JVM is synchronized, so file system * A more complicated mechanism is required to ensure global access across the JVM is synchronized, so file system
Expand All @@ -39,20 +39,20 @@ private FileUtil() {
*/ */
private static synchronized Object getLock(File file) throws IOException { private static synchronized Object getLock(File file) throws IOException {
String canonical = file.getAbsoluteFile().getCanonicalPath(); String canonical = file.getAbsoluteFile().getCanonicalPath();
if(!fileLocks.containsKey(canonical)) { if(!FILE_LOCKS.containsKey(canonical)) {
fileLocks.put(canonical, new Object()); FILE_LOCKS.put(canonical, new Object());
fileLockCounter.put(canonical, 0); FILE_LOCK_COUNTER.put(canonical, 0);
} }
fileLockCounter.put(canonical, fileLockCounter.get(canonical) + 1); FILE_LOCK_COUNTER.put(canonical, FILE_LOCK_COUNTER.get(canonical) + 1);
return fileLocks.get(canonical); return FILE_LOCKS.get(canonical);
} }


private static synchronized void freeLock(File file) throws IOException { private static synchronized void freeLock(File file) throws IOException {
String canonical = file.getAbsoluteFile().getCanonicalPath(); String canonical = file.getAbsoluteFile().getCanonicalPath();
fileLockCounter.put(canonical, fileLockCounter.get(canonical) - 1); FILE_LOCK_COUNTER.put(canonical, FILE_LOCK_COUNTER.get(canonical) - 1);
if(fileLockCounter.get(canonical) == 0) { if(FILE_LOCK_COUNTER.get(canonical) == 0) {
fileLockCounter.remove(canonical); FILE_LOCK_COUNTER.remove(canonical);
fileLocks.remove(canonical); FILE_LOCKS.remove(canonical);
} }
} }


Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/laytonsmith/PureUtilities/Common/Range.java
Expand Up @@ -80,14 +80,14 @@ public boolean isDecending() {
*/ */
public List<Integer> getRange() { public List<Integer> getRange() {
//Calculate the size once //Calculate the size once
double _size = Math.abs(leftBound - rightBound); double size = Math.abs(leftBound - rightBound);
if(!leftInclusive) { if(!leftInclusive) {
_size--; size--;
} }
if(rightInclusive) { if(rightInclusive) {
_size++; size++;
} }
final int size = (int) _size; final int finalSize = (int) size;
return new AbstractList<Integer>() { return new AbstractList<Integer>() {


@Override @Override
Expand All @@ -101,7 +101,7 @@ public Integer get(int index) {


@Override @Override
public int size() { public int size() {
return size; return finalSize;
} }
}; };
} }
Expand Down
Expand Up @@ -67,9 +67,9 @@ public static String GetString(InputStream in, String encoding) throws Unsupport
} }
InputStreamReader input; InputStreamReader input;
input = new InputStreamReader(new BufferedInputStream(in), encoding); input = new InputStreamReader(new BufferedInputStream(in), encoding);
final int CHARS_PER_PAGE = 5000; //counting spaces final int charsPerPage = 5000; //counting spaces
final char[] buffer = new char[CHARS_PER_PAGE]; final char[] buffer = new char[charsPerPage];
StringBuilder output = new StringBuilder(CHARS_PER_PAGE); StringBuilder output = new StringBuilder(charsPerPage);
try { try {
for(int read = input.read(buffer, 0, buffer.length); for(int read = input.read(buffer, 0, buffer.length);
read != -1; read != -1;
Expand Down
Expand Up @@ -518,7 +518,7 @@ public static List<String> ArgParser(String args) {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
char escape = 0; char escape = 0;
char quote = 0; char quote = 0;
boolean was_quote = false; boolean wasQuote = false;
for(int i = 0; i < args.length(); i++) { for(int i = 0; i < args.length(); i++) {
char ch = args.charAt(i); char ch = args.charAt(i);
if(quote != 0) { // we're in a quote if(quote != 0) { // we're in a quote
Expand All @@ -534,7 +534,7 @@ public static List<String> ArgParser(String args) {
continue; continue;
} else if(ch == quote) { // Specifying the same quote again terminates the quote. } else if(ch == quote) { // Specifying the same quote again terminates the quote.
quote = 0; quote = 0;
was_quote = true; wasQuote = true;
continue; continue;
} }
} else if(escape != 0) { } else if(escape != 0) {
Expand All @@ -546,10 +546,10 @@ public static List<String> ArgParser(String args) {
} else { // outside of quotes and escapes } else { // outside of quotes and escapes
switch(ch) { switch(ch) {
case ' ': // we can tokenize case ' ': // we can tokenize
if(was_quote || buf.length() != 0) { if(wasQuote || buf.length() != 0) {
arguments.add(buf.toString()); arguments.add(buf.toString());
buf = new StringBuilder(); buf = new StringBuilder();
was_quote = false; wasQuote = false;
} }
continue; continue;
case '"': // we can start quotes case '"': // we can start quotes
Expand All @@ -570,7 +570,7 @@ public static List<String> ArgParser(String args) {
if(escape != 0) { // makes trailing escapes be appended (erroneous string, though, IMO) if(escape != 0) { // makes trailing escapes be appended (erroneous string, though, IMO)
buf.append(escape); buf.append(escape);
} }
if(was_quote || buf.length() != 0) { // add the final string if(wasQuote || buf.length() != 0) { // add the final string
arguments.add(buf.toString()); arguments.add(buf.toString());
} }
return arguments; return arguments;
Expand Down

0 comments on commit 065ca39

Please sign in to comment.