repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java | UnrelatedCollectionContents.visitClassContext | @Override
public void visitClassContext(final ClassContext classContext) {
try {
stack = new OpcodeStack();
memberCollections = new HashMap<>();
memberSourceLineAnnotations = new HashMap<>();
super.visitClassContext(classContext);
} finally {
... | java | @Override
public void visitClassContext(final ClassContext classContext) {
try {
stack = new OpcodeStack();
memberCollections = new HashMap<>();
memberSourceLineAnnotations = new HashMap<>();
super.visitClassContext(classContext);
} finally {
... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"final",
"ClassContext",
"classContext",
")",
"{",
"try",
"{",
"stack",
"=",
"new",
"OpcodeStack",
"(",
")",
";",
"memberCollections",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"memberSourceLineAnn... | implements the visitor to create and destroy the stack and member collections
@param classContext
the context object for the currently parsed class | [
"implements",
"the",
"visitor",
"to",
"create",
"and",
"destroy",
"the",
"stack",
"and",
"member",
"collections"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java#L81-L93 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java | UnrelatedCollectionContents.visitCode | @Override
public void visitCode(final Code obj) {
try {
localCollections = new HashMap<>();
localScopeEnds = new HashMap<>();
localSourceLineAnnotations = new HashMap<>();
stack.resetForMethodEntry(this);
super.visitCode(obj);
} finally {
... | java | @Override
public void visitCode(final Code obj) {
try {
localCollections = new HashMap<>();
localScopeEnds = new HashMap<>();
localSourceLineAnnotations = new HashMap<>();
stack.resetForMethodEntry(this);
super.visitCode(obj);
} finally {
... | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"final",
"Code",
"obj",
")",
"{",
"try",
"{",
"localCollections",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"localScopeEnds",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"localSourceLineAnnotations",
"... | implements the visitor to reset the opcode stack, and clear the various collections
@param obj
the currently parsed code block | [
"implements",
"the",
"visitor",
"to",
"reset",
"the",
"opcode",
"stack",
"and",
"clear",
"the",
"various",
"collections"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java#L101-L114 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java | UnrelatedCollectionContents.sawOpcode | @Override
public void sawOpcode(final int seen) {
try {
stack.precomputation(this);
BitSet regs = localScopeEnds.remove(Integer.valueOf(getPC()));
if (regs != null) {
int i = regs.nextSetBit(0);
while (i >= 0) {
localCo... | java | @Override
public void sawOpcode(final int seen) {
try {
stack.precomputation(this);
BitSet regs = localScopeEnds.remove(Integer.valueOf(getPC()));
if (regs != null) {
int i = regs.nextSetBit(0);
while (i >= 0) {
localCo... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"final",
"int",
"seen",
")",
"{",
"try",
"{",
"stack",
".",
"precomputation",
"(",
"this",
")",
";",
"BitSet",
"regs",
"=",
"localScopeEnds",
".",
"remove",
"(",
"Integer",
".",
"valueOf",
"(",
"getPC"... | implements the visitor to look for collection method calls that put objects into the collection that are unrelated by anything besides java.lang.Objecct
@param seen
the currently parsed opcode | [
"implements",
"the",
"visitor",
"to",
"look",
"for",
"collection",
"method",
"calls",
"that",
"put",
"objects",
"into",
"the",
"collection",
"that",
"are",
"unrelated",
"by",
"anything",
"besides",
"java",
".",
"lang",
".",
"Objecct"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java#L122-L170 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java | UnrelatedCollectionContents.mergeItem | private void mergeItem(final Set<String> supers, final Set<SourceLineAnnotation> sla, final OpcodeStack.Item addItm) throws ClassNotFoundException {
if (supers.isEmpty()) {
return;
}
Set<String> s = new HashSet<>();
addNewItem(s, addItm);
if (s.isEmpty()) {
... | java | private void mergeItem(final Set<String> supers, final Set<SourceLineAnnotation> sla, final OpcodeStack.Item addItm) throws ClassNotFoundException {
if (supers.isEmpty()) {
return;
}
Set<String> s = new HashSet<>();
addNewItem(s, addItm);
if (s.isEmpty()) {
... | [
"private",
"void",
"mergeItem",
"(",
"final",
"Set",
"<",
"String",
">",
"supers",
",",
"final",
"Set",
"<",
"SourceLineAnnotation",
">",
"sla",
",",
"final",
"OpcodeStack",
".",
"Item",
"addItm",
")",
"throws",
"ClassNotFoundException",
"{",
"if",
"(",
"sup... | intersects the set of possible superclass that this collection might have seen before with this one. If we find that there is no commonality between
superclasses, report it as a bug.
@param supers
the collection of possible superclass/interfaces that has been seen for this collection thus far
@param sla
the location o... | [
"intersects",
"the",
"set",
"of",
"possible",
"superclass",
"that",
"this",
"collection",
"might",
"have",
"seen",
"before",
"with",
"this",
"one",
".",
"If",
"we",
"find",
"that",
"there",
"is",
"no",
"commonality",
"between",
"superclasses",
"report",
"it",
... | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java#L245-L273 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UnsynchronizedSingletonFieldWrites.java | UnsynchronizedSingletonFieldWrites.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
try {
JavaClass cls = classContext.getJavaClass();
if (isSingleton(cls)) {
syncBlockBranchResetValues = new HashMap<>();
stack = new OpcodeStack();
super.visitClassCon... | java | @Override
public void visitClassContext(ClassContext classContext) {
try {
JavaClass cls = classContext.getJavaClass();
if (isSingleton(cls)) {
syncBlockBranchResetValues = new HashMap<>();
stack = new OpcodeStack();
super.visitClassCon... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"try",
"{",
"JavaClass",
"cls",
"=",
"classContext",
".",
"getJavaClass",
"(",
")",
";",
"if",
"(",
"isSingleton",
"(",
"cls",
")",
")",
"{",
"syncBlockBra... | implements the visitor to look for classes that are singletons
@param classContext
the context object of the currently parsed class | [
"implements",
"the",
"visitor",
"to",
"look",
"for",
"classes",
"that",
"are",
"singletons"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UnsynchronizedSingletonFieldWrites.java#L89-L102 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UnsynchronizedSingletonFieldWrites.java | UnsynchronizedSingletonFieldWrites.visitCode | @Override
public void visitCode(Code obj) {
Method m = getMethod();
if (isIgnorableMethod(m)) {
return;
}
stack.resetForMethodEntry(this);
syncBlockBranchResetValues.clear();
syncBlockCount = 0;
super.visitCode(obj);
} | java | @Override
public void visitCode(Code obj) {
Method m = getMethod();
if (isIgnorableMethod(m)) {
return;
}
stack.resetForMethodEntry(this);
syncBlockBranchResetValues.clear();
syncBlockCount = 0;
super.visitCode(obj);
} | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"Method",
"m",
"=",
"getMethod",
"(",
")",
";",
"if",
"(",
"isIgnorableMethod",
"(",
"m",
")",
")",
"{",
"return",
";",
"}",
"stack",
".",
"resetForMethodEntry",
"(",
"this",... | implements the visitor to look for methods that could possibly be 'normal' methods where a field is written to
@param obj
the currently parsed code block | [
"implements",
"the",
"visitor",
"to",
"look",
"for",
"methods",
"that",
"could",
"possibly",
"be",
"normal",
"methods",
"where",
"a",
"field",
"is",
"written",
"to"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UnsynchronizedSingletonFieldWrites.java#L110-L122 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ConflatingResourcesAndFiles.java | ConflatingResourcesAndFiles.sawOpcode | @Override
public void sawOpcode(int seen) {
boolean sawResource = false;
try {
stack.precomputation(this);
if (seen == Const.INVOKEVIRTUAL) {
sawResource = processInvokeVirtual();
} else if (seen == Const.INVOKESPECIAL) {
sawResour... | java | @Override
public void sawOpcode(int seen) {
boolean sawResource = false;
try {
stack.precomputation(this);
if (seen == Const.INVOKEVIRTUAL) {
sawResource = processInvokeVirtual();
} else if (seen == Const.INVOKESPECIAL) {
sawResour... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"boolean",
"sawResource",
"=",
"false",
";",
"try",
"{",
"stack",
".",
"precomputation",
"(",
"this",
")",
";",
"if",
"(",
"seen",
"==",
"Const",
".",
"INVOKEVIRTUAL",
")",
"... | overrides the visitor to look conflated use of resources and files | [
"overrides",
"the",
"visitor",
"to",
"look",
"conflated",
"use",
"of",
"resources",
"and",
"files"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ConflatingResourcesAndFiles.java#L86-L105 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java | PossiblyRedundantMethodCalls.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
try {
stack = new OpcodeStack();
localMethodCalls = new HashMap<>();
fieldMethodCalls = new HashMap<>();
staticMethodCalls = new HashMap<>();
branchTargets = new BitSet();
super.visitClassContext(classContext);
} finally {
st... | java | @Override
public void visitClassContext(ClassContext classContext) {
try {
stack = new OpcodeStack();
localMethodCalls = new HashMap<>();
fieldMethodCalls = new HashMap<>();
staticMethodCalls = new HashMap<>();
branchTargets = new BitSet();
super.visitClassContext(classContext);
} finally {
st... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"try",
"{",
"stack",
"=",
"new",
"OpcodeStack",
"(",
")",
";",
"localMethodCalls",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"fieldMethodCalls",
"=",
"ne... | implements the visitor to create and clear the stack, method call maps, and
branch targets
@param classContext the context object of the currently visited class | [
"implements",
"the",
"visitor",
"to",
"create",
"and",
"clear",
"the",
"stack",
"method",
"call",
"maps",
"and",
"branch",
"targets"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java#L216-L232 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java | PossiblyRedundantMethodCalls.getBugPriority | private static int getBugPriority(String methodName, MethodInfo mi) {
if (Values.STATIC_INITIALIZER.equals(methodName)) {
return LOW_PRIORITY;
}
if ((mi.getNumBytes() >= highByteCountLimit) || (mi.getNumMethodCalls() >= highMethodCallLimit)) {
return HIGH_PRIORITY;
}
if ((mi.getNumBytes() >= normalByt... | java | private static int getBugPriority(String methodName, MethodInfo mi) {
if (Values.STATIC_INITIALIZER.equals(methodName)) {
return LOW_PRIORITY;
}
if ((mi.getNumBytes() >= highByteCountLimit) || (mi.getNumMethodCalls() >= highMethodCallLimit)) {
return HIGH_PRIORITY;
}
if ((mi.getNumBytes() >= normalByt... | [
"private",
"static",
"int",
"getBugPriority",
"(",
"String",
"methodName",
",",
"MethodInfo",
"mi",
")",
"{",
"if",
"(",
"Values",
".",
"STATIC_INITIALIZER",
".",
"equals",
"(",
"methodName",
")",
")",
"{",
"return",
"LOW_PRIORITY",
";",
"}",
"if",
"(",
"(... | returns the bug priority based on metrics about the method
@param methodName TODO
@param mi metrics about the method
@return the bug priority | [
"returns",
"the",
"bug",
"priority",
"based",
"on",
"metrics",
"about",
"the",
"method"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java#L473-L491 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java | PossiblyRedundantMethodCalls.isRiskyName | private static boolean isRiskyName(String className, String methodName) {
if (riskyClassNames.contains(className)) {
return true;
}
String qualifiedMethodName = className + '.' + methodName;
if (riskyMethodNameContents.contains(qualifiedMethodName)) {
return true;
}
for (String riskyName : riskyMeth... | java | private static boolean isRiskyName(String className, String methodName) {
if (riskyClassNames.contains(className)) {
return true;
}
String qualifiedMethodName = className + '.' + methodName;
if (riskyMethodNameContents.contains(qualifiedMethodName)) {
return true;
}
for (String riskyName : riskyMeth... | [
"private",
"static",
"boolean",
"isRiskyName",
"(",
"String",
"className",
",",
"String",
"methodName",
")",
"{",
"if",
"(",
"riskyClassNames",
".",
"contains",
"(",
"className",
")",
")",
"{",
"return",
"true",
";",
"}",
"String",
"qualifiedMethodName",
"=",
... | returns true if the class or method name contains a pattern that is
considered likely to be this modifying
@param className the class name to check
@param methodName the method name to check
@return whether the method sounds like it modifies this | [
"returns",
"true",
"if",
"the",
"class",
"or",
"method",
"name",
"contains",
"a",
"pattern",
"that",
"is",
"considered",
"likely",
"to",
"be",
"this",
"modifying"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java#L501-L518 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java | PossiblyRedundantMethodCalls.getLineNumber | private int getLineNumber(int pc) {
LineNumberTable lnt = getMethod().getLineNumberTable();
if (lnt == null) {
return pc;
}
LineNumber[] lns = lnt.getLineNumberTable();
if (lns == null) {
return pc;
}
if (pc > lns[lns.length - 1].getStartPC()) {
return lns[lns.length - 1].getLineNumber();
}
... | java | private int getLineNumber(int pc) {
LineNumberTable lnt = getMethod().getLineNumberTable();
if (lnt == null) {
return pc;
}
LineNumber[] lns = lnt.getLineNumberTable();
if (lns == null) {
return pc;
}
if (pc > lns[lns.length - 1].getStartPC()) {
return lns[lns.length - 1].getLineNumber();
}
... | [
"private",
"int",
"getLineNumber",
"(",
"int",
"pc",
")",
"{",
"LineNumberTable",
"lnt",
"=",
"getMethod",
"(",
")",
".",
"getLineNumberTable",
"(",
")",
";",
"if",
"(",
"lnt",
"==",
"null",
")",
"{",
"return",
"pc",
";",
"}",
"LineNumber",
"[",
"]",
... | returns the source line number for the pc, or just the pc if the line number
table doesn't exist
@param pc current pc
@return the line number | [
"returns",
"the",
"source",
"line",
"number",
"for",
"the",
"pc",
"or",
"just",
"the",
"pc",
"if",
"the",
"line",
"number",
"table",
"doesn",
"t",
"exist"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java#L527-L557 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/CloneUsability.java | CloneUsability.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
if (cloneClass == null) {
return;
}
try {
cls = classContext.getJavaClass();
if (cls.implementationOf(cloneClass)) {
clsName = cls.getClassName();
stack ... | java | @Override
public void visitClassContext(ClassContext classContext) {
if (cloneClass == null) {
return;
}
try {
cls = classContext.getJavaClass();
if (cls.implementationOf(cloneClass)) {
clsName = cls.getClassName();
stack ... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"if",
"(",
"cloneClass",
"==",
"null",
")",
"{",
"return",
";",
"}",
"try",
"{",
"cls",
"=",
"classContext",
".",
"getJavaClass",
"(",
")",
";",
"if",
... | overrides the visitor to check for classes that implement Cloneable.
@param classContext
the context object that holds the JavaClass being parsed | [
"overrides",
"the",
"visitor",
"to",
"check",
"for",
"classes",
"that",
"implement",
"Cloneable",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/CloneUsability.java#L75-L95 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/CloneUsability.java | CloneUsability.sawOpcode | @Override
public void sawOpcode(int seen) {
try {
if ((seen == Const.ATHROW) && (stack.getStackDepth() > 0)) {
OpcodeStack.Item item = stack.getStackItem(0);
if ("Ljava/lang/CloneNotSupportedException;".equals(item.getSignature())) {
throwsCNFE... | java | @Override
public void sawOpcode(int seen) {
try {
if ((seen == Const.ATHROW) && (stack.getStackDepth() > 0)) {
OpcodeStack.Item item = stack.getStackItem(0);
if ("Ljava/lang/CloneNotSupportedException;".equals(item.getSignature())) {
throwsCNFE... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"try",
"{",
"if",
"(",
"(",
"seen",
"==",
"Const",
".",
"ATHROW",
")",
"&&",
"(",
"stack",
".",
"getStackDepth",
"(",
")",
">",
"0",
")",
")",
"{",
"OpcodeStack",
".",
... | overrides the visitor to look for a CloneNotSupported being thrown
@param seen
the currently parsed opcode | [
"overrides",
"the",
"visitor",
"to",
"look",
"for",
"a",
"CloneNotSupported",
"being",
"thrown"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/CloneUsability.java#L151-L163 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessInstanceRetrieval.java | NeedlessInstanceRetrieval.visitCode | @Override
public void visitCode(Code obj) {
try {
lnTable = obj.getLineNumberTable();
if (lnTable != null) {
state = State.SEEN_NOTHING;
invokePC = -1;
returnType = null;
super.visitCode(obj);
}
} fin... | java | @Override
public void visitCode(Code obj) {
try {
lnTable = obj.getLineNumberTable();
if (lnTable != null) {
state = State.SEEN_NOTHING;
invokePC = -1;
returnType = null;
super.visitCode(obj);
}
} fin... | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"try",
"{",
"lnTable",
"=",
"obj",
".",
"getLineNumberTable",
"(",
")",
";",
"if",
"(",
"lnTable",
"!=",
"null",
")",
"{",
"state",
"=",
"State",
".",
"SEEN_NOTHING",
";",
... | overrides the interface to collect the line number table, and reset state
@param obj
the content object of the currently parsed code | [
"overrides",
"the",
"interface",
"to",
"collect",
"the",
"line",
"number",
"table",
"and",
"reset",
"state"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessInstanceRetrieval.java#L65-L78 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessInstanceRetrieval.java | NeedlessInstanceRetrieval.sawOpcode | @Override
public void sawOpcode(int seen) {
switch (state) {
case SEEN_NOTHING:
if ((seen == Const.INVOKEINTERFACE) || (seen == Const.INVOKEVIRTUAL)) {
String sig = getSigConstantOperand();
String returnSig = SignatureUtils.getReturnSignatu... | java | @Override
public void sawOpcode(int seen) {
switch (state) {
case SEEN_NOTHING:
if ((seen == Const.INVOKEINTERFACE) || (seen == Const.INVOKEVIRTUAL)) {
String sig = getSigConstantOperand();
String returnSig = SignatureUtils.getReturnSignatu... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"switch",
"(",
"state",
")",
"{",
"case",
"SEEN_NOTHING",
":",
"if",
"(",
"(",
"seen",
"==",
"Const",
".",
"INVOKEINTERFACE",
")",
"||",
"(",
"seen",
"==",
"Const",
".",
"I... | overrides the interface to find accesses of static variables off of an instance immediately fetched from a method call.
@param seen
the opcode of the currently visited instruction | [
"overrides",
"the",
"interface",
"to",
"find",
"accesses",
"of",
"static",
"variables",
"off",
"of",
"an",
"instance",
"immediately",
"fetched",
"from",
"a",
"method",
"call",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessInstanceRetrieval.java#L86-L134 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java | CyclomaticComplexity.visitClassContext | @Override
public void visitClassContext(final ClassContext context) {
try {
classContext = context;
classContext.getJavaClass().accept(this);
} finally {
classContext = null;
}
} | java | @Override
public void visitClassContext(final ClassContext context) {
try {
classContext = context;
classContext.getJavaClass().accept(this);
} finally {
classContext = null;
}
} | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"final",
"ClassContext",
"context",
")",
"{",
"try",
"{",
"classContext",
"=",
"context",
";",
"classContext",
".",
"getJavaClass",
"(",
")",
".",
"accept",
"(",
"this",
")",
";",
"}",
"finally",
... | overrides the visitor to store the class context
@param context
the context object for the currently parsed class | [
"overrides",
"the",
"visitor",
"to",
"store",
"the",
"class",
"context"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java#L70-L78 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java | CyclomaticComplexity.visitMethod | @Override
public void visitMethod(final Method obj) {
try {
if (obj.isSynthetic()) {
return;
}
Code code = obj.getCode();
if (code == null) {
return;
}
// There really is no valid relationship between ... | java | @Override
public void visitMethod(final Method obj) {
try {
if (obj.isSynthetic()) {
return;
}
Code code = obj.getCode();
if (code == null) {
return;
}
// There really is no valid relationship between ... | [
"@",
"Override",
"public",
"void",
"visitMethod",
"(",
"final",
"Method",
"obj",
")",
"{",
"try",
"{",
"if",
"(",
"obj",
".",
"isSynthetic",
"(",
")",
")",
"{",
"return",
";",
"}",
"Code",
"code",
"=",
"obj",
".",
"getCode",
"(",
")",
";",
"if",
... | overrides the visitor to navigate the basic block list to count branches
@param obj
the method of the currently parsed method | [
"overrides",
"the",
"visitor",
"to",
"navigate",
"the",
"basic",
"block",
"list",
"to",
"count",
"branches"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java#L94-L159 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java | JPAIssues.visitCode | @Override
public void visitCode(Code obj) {
Method m = getMethod();
if (m.isSynthetic()) {
return;
}
isPublic = m.isPublic();
stack.resetForMethodEntry(this);
super.visitCode(obj);
} | java | @Override
public void visitCode(Code obj) {
Method m = getMethod();
if (m.isSynthetic()) {
return;
}
isPublic = m.isPublic();
stack.resetForMethodEntry(this);
super.visitCode(obj);
} | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"Method",
"m",
"=",
"getMethod",
"(",
")",
";",
"if",
"(",
"m",
".",
"isSynthetic",
"(",
")",
")",
"{",
"return",
";",
"}",
"isPublic",
"=",
"m",
".",
"isPublic",
"(",
... | implements the visitor to reset the opcode stack, Note that the synthetic check is done in both visitMethod and visitCode as visitMethod is not a proper
listener stopping method. We don't want to report issues reported in visitMethod if it is synthetic, but we also don't want it to get into sawOpcode, so
that is why it... | [
"implements",
"the",
"visitor",
"to",
"reset",
"the",
"opcode",
"stack",
"Note",
"that",
"the",
"synthetic",
"check",
"is",
"done",
"in",
"both",
"visitMethod",
"and",
"visitCode",
"as",
"visitMethod",
"is",
"not",
"a",
"proper",
"listener",
"stopping",
"metho... | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java#L188-L200 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java | JPAIssues.catalogClass | private void catalogClass(JavaClass clz) {
transactionalMethods = new HashMap<>();
isEntity = false;
hasId = false;
hasGeneratedValue = false;
hasEagerOneToMany = false;
hasHCEquals = false;
for (AnnotationEntry entry : clz.getAnnotationEntries()) {
i... | java | private void catalogClass(JavaClass clz) {
transactionalMethods = new HashMap<>();
isEntity = false;
hasId = false;
hasGeneratedValue = false;
hasEagerOneToMany = false;
hasHCEquals = false;
for (AnnotationEntry entry : clz.getAnnotationEntries()) {
i... | [
"private",
"void",
"catalogClass",
"(",
"JavaClass",
"clz",
")",
"{",
"transactionalMethods",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"isEntity",
"=",
"false",
";",
"hasId",
"=",
"false",
";",
"hasGeneratedValue",
"=",
"false",
";",
"hasEagerOneToMany",
... | parses the current class for spring-tx and jpa annotations, as well as hashCode and equals methods.
@param clz
the currently parsed class | [
"parses",
"the",
"current",
"class",
"for",
"spring",
"-",
"tx",
"and",
"jpa",
"annotations",
"as",
"well",
"as",
"hashCode",
"and",
"equals",
"methods",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java#L275-L302 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java | JPAIssues.catalogFieldOrMethod | private void catalogFieldOrMethod(FieldOrMethod fm) {
for (AnnotationEntry entry : fm.getAnnotationEntries()) {
String type = entry.getAnnotationType();
switch (type) {
case "Lorg/springframework/transaction/annotation/Transactional;":
if (fm instanceo... | java | private void catalogFieldOrMethod(FieldOrMethod fm) {
for (AnnotationEntry entry : fm.getAnnotationEntries()) {
String type = entry.getAnnotationType();
switch (type) {
case "Lorg/springframework/transaction/annotation/Transactional;":
if (fm instanceo... | [
"private",
"void",
"catalogFieldOrMethod",
"(",
"FieldOrMethod",
"fm",
")",
"{",
"for",
"(",
"AnnotationEntry",
"entry",
":",
"fm",
".",
"getAnnotationEntries",
"(",
")",
")",
"{",
"String",
"type",
"=",
"entry",
".",
"getAnnotationType",
"(",
")",
";",
"swi... | parses a field or method for spring-tx or jpa annotations
@param fm
the currently parsed field or method | [
"parses",
"a",
"field",
"or",
"method",
"for",
"spring",
"-",
"tx",
"or",
"jpa",
"annotations"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java#L310-L355 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java | JPAIssues.getDeclaredExceptions | private Set<JavaClass> getDeclaredExceptions(Method method) throws ClassNotFoundException {
ExceptionTable et = method.getExceptionTable();
if ((et == null) || (et.getLength() == 0)) {
return Collections.<JavaClass> emptySet();
}
Set<JavaClass> exceptions = new HashSet<>();
... | java | private Set<JavaClass> getDeclaredExceptions(Method method) throws ClassNotFoundException {
ExceptionTable et = method.getExceptionTable();
if ((et == null) || (et.getLength() == 0)) {
return Collections.<JavaClass> emptySet();
}
Set<JavaClass> exceptions = new HashSet<>();
... | [
"private",
"Set",
"<",
"JavaClass",
">",
"getDeclaredExceptions",
"(",
"Method",
"method",
")",
"throws",
"ClassNotFoundException",
"{",
"ExceptionTable",
"et",
"=",
"method",
".",
"getExceptionTable",
"(",
")",
";",
"if",
"(",
"(",
"et",
"==",
"null",
")",
... | retrieves the set of non-runtime exceptions that are declared to be thrown by the method
@param method
the currently parsed method
@return the set of exceptions thrown
@throws ClassNotFoundException
if an exception class is not found | [
"retrieves",
"the",
"set",
"of",
"non",
"-",
"runtime",
"exceptions",
"that",
"are",
"declared",
"to",
"be",
"thrown",
"by",
"the",
"method"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java#L445-L460 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java | BloatedSynchronizedBlock.visitCode | @Override
public void visitCode(Code obj) {
Method m = getMethod();
if (prescreen(m)) {
if (m.isSynchronized()) {
syncPC = 0;
} else {
syncPC = -1;
}
isStatic = m.isStatic();
unsafeAliases.clear();
... | java | @Override
public void visitCode(Code obj) {
Method m = getMethod();
if (prescreen(m)) {
if (m.isSynchronized()) {
syncPC = 0;
} else {
syncPC = -1;
}
isStatic = m.isStatic();
unsafeAliases.clear();
... | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"Method",
"m",
"=",
"getMethod",
"(",
")",
";",
"if",
"(",
"prescreen",
"(",
"m",
")",
")",
"{",
"if",
"(",
"m",
".",
"isSynchronized",
"(",
")",
")",
"{",
"syncPC",
"=... | implement the visitor to reset the sync count, the stack, and gather some information
@param obj
the context object for the currently parsed method | [
"implement",
"the",
"visitor",
"to",
"reset",
"the",
"sync",
"count",
"the",
"stack",
"and",
"gather",
"some",
"information"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java#L102-L118 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java | BloatedSynchronizedBlock.sawOpcode | @Override
public void sawOpcode(int seen) {
try {
stack.precomputation(this);
if (unsafeCallOccurred && OpcodeUtils.isAStore(seen)) {
int storeReg = RegisterUtils.getAStoreReg(this, seen);
if (storeReg >= 0) {
unsafeAliases.set(sto... | java | @Override
public void sawOpcode(int seen) {
try {
stack.precomputation(this);
if (unsafeCallOccurred && OpcodeUtils.isAStore(seen)) {
int storeReg = RegisterUtils.getAStoreReg(this, seen);
if (storeReg >= 0) {
unsafeAliases.set(sto... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"try",
"{",
"stack",
".",
"precomputation",
"(",
"this",
")",
";",
"if",
"(",
"unsafeCallOccurred",
"&&",
"OpcodeUtils",
".",
"isAStore",
"(",
"seen",
")",
")",
"{",
"int",
"... | implement the visitor to find bloated sync blocks. This implementation only checks the outer most block
@param seen
the opcode of the currently parsed instruction | [
"implement",
"the",
"visitor",
"to",
"find",
"bloated",
"sync",
"blocks",
".",
"This",
"implementation",
"only",
"checks",
"the",
"outer",
"most",
"block"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java#L126-L187 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java | OptionalIssues.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
currentClass = classContext.getJavaClass();
if (currentClass.getMajor() >= Const.MAJOR_1_8) {
try {
stack = new OpcodeStack();
activeStackOps = new ArrayDeque<>();
super.... | java | @Override
public void visitClassContext(ClassContext classContext) {
currentClass = classContext.getJavaClass();
if (currentClass.getMajor() >= Const.MAJOR_1_8) {
try {
stack = new OpcodeStack();
activeStackOps = new ArrayDeque<>();
super.... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"currentClass",
"=",
"classContext",
".",
"getJavaClass",
"(",
")",
";",
"if",
"(",
"currentClass",
".",
"getMajor",
"(",
")",
">=",
"Const",
".",
"MAJOR_1_8... | implements the visitor to filter out pre-1.8 classes, for 1.8+ classes, it creates the opcode stack and active stack ops
@param classContext
the context object of the currently parsed class | [
"implements",
"the",
"visitor",
"to",
"filter",
"out",
"pre",
"-",
"1",
".",
"8",
"classes",
"for",
"1",
".",
"8",
"+",
"classes",
"it",
"creates",
"the",
"opcode",
"stack",
"and",
"active",
"stack",
"ops"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java#L125-L140 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java | OptionalIssues.visitCode | @Override
public void visitCode(Code obj) {
stack.resetForMethodEntry(this);
activeStackOps.clear();
super.visitCode(obj);
} | java | @Override
public void visitCode(Code obj) {
stack.resetForMethodEntry(this);
activeStackOps.clear();
super.visitCode(obj);
} | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"stack",
".",
"resetForMethodEntry",
"(",
"this",
")",
";",
"activeStackOps",
".",
"clear",
"(",
")",
";",
"super",
".",
"visitCode",
"(",
"obj",
")",
";",
"}"
] | implements the visitor clear the stacks
@param obj
the context object of the currently parsed code block | [
"implements",
"the",
"visitor",
"clear",
"the",
"stacks"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java#L148-L153 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java | OptionalIssues.isTrivialStackOps | private boolean isTrivialStackOps() {
int invokeCount = 0;
for (ActiveStackOp op : activeStackOps) {
if (INVOKE_OPS.get(op.getOpcode())) {
invokeCount++;
}
}
if (invokeCount == 1) {
FQMethod method = activeStackOps.getLast().getMethod... | java | private boolean isTrivialStackOps() {
int invokeCount = 0;
for (ActiveStackOp op : activeStackOps) {
if (INVOKE_OPS.get(op.getOpcode())) {
invokeCount++;
}
}
if (invokeCount == 1) {
FQMethod method = activeStackOps.getLast().getMethod... | [
"private",
"boolean",
"isTrivialStackOps",
"(",
")",
"{",
"int",
"invokeCount",
"=",
"0",
";",
"for",
"(",
"ActiveStackOp",
"op",
":",
"activeStackOps",
")",
"{",
"if",
"(",
"INVOKE_OPS",
".",
"get",
"(",
"op",
".",
"getOpcode",
"(",
")",
")",
")",
"{"... | returns whether the set of operations that contributed to the current stack form, are trivial or not, specifically boxing a primitive value, or appending
to strings or such.
@return the operations that caused the current stack to exist are trivial | [
"returns",
"whether",
"the",
"set",
"of",
"operations",
"that",
"contributed",
"to",
"the",
"current",
"stack",
"form",
"are",
"trivial",
"or",
"not",
"specifically",
"boxing",
"a",
"primitive",
"value",
"or",
"appending",
"to",
"strings",
"or",
"such",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java#L276-L299 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java | OptionalIssues.getLambdaMethod | @Nullable
private Method getLambdaMethod(String methodName) {
for (Method method : currentClass.getMethods()) {
if (methodName.equals(method.getName())) {
return method;
}
}
return null;
} | java | @Nullable
private Method getLambdaMethod(String methodName) {
for (Method method : currentClass.getMethods()) {
if (methodName.equals(method.getName())) {
return method;
}
}
return null;
} | [
"@",
"Nullable",
"private",
"Method",
"getLambdaMethod",
"(",
"String",
"methodName",
")",
"{",
"for",
"(",
"Method",
"method",
":",
"currentClass",
".",
"getMethods",
"(",
")",
")",
"{",
"if",
"(",
"methodName",
".",
"equals",
"(",
"method",
".",
"getName... | finds the bootstrap method for a lambda (invokedynamic call. As findbugs doesn't support bcel 6, have to cheat a little here.
@param methodName
the lambda name
@return the method object if it exists | [
"finds",
"the",
"bootstrap",
"method",
"for",
"a",
"lambda",
"(",
"invokedynamic",
"call",
".",
"As",
"findbugs",
"doesn",
"t",
"support",
"bcel",
"6",
"have",
"to",
"cheat",
"a",
"little",
"here",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java#L308-L317 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java | BackportReusePublicIdentifiers.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
JavaClass cls = classContext.getJavaClass();
clsVersion = cls.getMajor();
super.visitClassContext(classContext);
} | java | @Override
public void visitClassContext(ClassContext classContext) {
JavaClass cls = classContext.getJavaClass();
clsVersion = cls.getMajor();
super.visitClassContext(classContext);
} | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"JavaClass",
"cls",
"=",
"classContext",
".",
"getJavaClass",
"(",
")",
";",
"clsVersion",
"=",
"cls",
".",
"getMajor",
"(",
")",
";",
"super",
".",
"visit... | overrides the visitor to make sure this is a 'modern' class better than 1.4
@param classContext
the currently parsed class | [
"overrides",
"the",
"visitor",
"to",
"make",
"sure",
"this",
"is",
"a",
"modern",
"class",
"better",
"than",
"1",
".",
"4"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java#L75-L80 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java | BackportReusePublicIdentifiers.sawOpcode | @Override
public void sawOpcode(int seen) {
stack.precomputation(this);
switch (seen) {
case Const.INVOKESTATIC: {
String className = getClassConstantOperand();
for (Backports backport : BACKPORTS) {
if (className.startsWith(backport.g... | java | @Override
public void sawOpcode(int seen) {
stack.precomputation(this);
switch (seen) {
case Const.INVOKESTATIC: {
String className = getClassConstantOperand();
for (Backports backport : BACKPORTS) {
if (className.startsWith(backport.g... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"stack",
".",
"precomputation",
"(",
"this",
")",
";",
"switch",
"(",
"seen",
")",
"{",
"case",
"Const",
".",
"INVOKESTATIC",
":",
"{",
"String",
"className",
"=",
"getClassCon... | overrides the visitor to look for method calls to the emory backport concurrent library, or threeten bp library when the now built-in versions are
available
@param seen
the currently parsed opcode | [
"overrides",
"the",
"visitor",
"to",
"look",
"for",
"method",
"calls",
"to",
"the",
"emory",
"backport",
"concurrent",
"library",
"or",
"threeten",
"bp",
"library",
"when",
"the",
"now",
"built",
"-",
"in",
"versions",
"are",
"available"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java#L89-L122 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java | BackportReusePublicIdentifiers.reportBug | private void reportBug(Library library) {
bugReporter.reportBug(new BugInstance(this, BugType.BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS.name(), NORMAL_PRIORITY).addClass(this).addMethod(this)
.addSourceLine(this).addString(library.name()));
} | java | private void reportBug(Library library) {
bugReporter.reportBug(new BugInstance(this, BugType.BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS.name(), NORMAL_PRIORITY).addClass(this).addMethod(this)
.addSourceLine(this).addString(library.name()));
} | [
"private",
"void",
"reportBug",
"(",
"Library",
"library",
")",
"{",
"bugReporter",
".",
"reportBug",
"(",
"new",
"BugInstance",
"(",
"this",
",",
"BugType",
".",
"BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS",
".",
"name",
"(",
")",
",",
"NORMAL_PRIORITY",
")",
".",
... | issues a new bug at this location
@param library
the type of backport library that is in use | [
"issues",
"a",
"new",
"bug",
"at",
"this",
"location"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java#L130-L133 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java | LoggerOddities.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
try {
stack = new OpcodeStack();
nameOfThisClass = SignatureUtils.getNonAnonymousPortion(classContext.getJavaClass().getClassName());
formatterLoggers = new HashSet<>();
super.visitClassConte... | java | @Override
public void visitClassContext(ClassContext classContext) {
try {
stack = new OpcodeStack();
nameOfThisClass = SignatureUtils.getNonAnonymousPortion(classContext.getJavaClass().getClassName());
formatterLoggers = new HashSet<>();
super.visitClassConte... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"try",
"{",
"stack",
"=",
"new",
"OpcodeStack",
"(",
")",
";",
"nameOfThisClass",
"=",
"SignatureUtils",
".",
"getNonAnonymousPortion",
"(",
"classContext",
".",... | implements the visitor to discover what the class name is if it is a normal class, or the owning class, if the class is an anonymous class.
@param classContext
the context object of the currently parsed class | [
"implements",
"the",
"visitor",
"to",
"discover",
"what",
"the",
"class",
"name",
"is",
"if",
"it",
"is",
"a",
"normal",
"class",
"or",
"the",
"owning",
"class",
"if",
"the",
"class",
"is",
"an",
"anonymous",
"class",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java#L135-L146 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java | LoggerOddities.checkForProblemsWithLoggerMethods | @SuppressWarnings("unchecked")
private void checkForProblemsWithLoggerMethods() throws ClassNotFoundException {
String callingClsName = getClassConstantOperand();
if (!(callingClsName.endsWith("Log") || (callingClsName.endsWith("Logger"))) || (stack.getStackDepth() == 0)) {
return;
... | java | @SuppressWarnings("unchecked")
private void checkForProblemsWithLoggerMethods() throws ClassNotFoundException {
String callingClsName = getClassConstantOperand();
if (!(callingClsName.endsWith("Log") || (callingClsName.endsWith("Logger"))) || (stack.getStackDepth() == 0)) {
return;
... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"checkForProblemsWithLoggerMethods",
"(",
")",
"throws",
"ClassNotFoundException",
"{",
"String",
"callingClsName",
"=",
"getClassConstantOperand",
"(",
")",
";",
"if",
"(",
"!",
"(",
"callingClsNa... | looks for a variety of logging issues with log statements
@throws ClassNotFoundException
if the exception class, or a parent class can't be found | [
"looks",
"for",
"a",
"variety",
"of",
"logging",
"issues",
"with",
"log",
"statements"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java#L379-L395 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java | LoggerOddities.getVarArgsParmCount | @SuppressWarnings("unchecked")
private int getVarArgsParmCount(String signature) {
if (SignatureBuilder.SIG_STRING_AND_OBJECT_TO_VOID.equals(signature)) {
return 1;
}
if (SIG_STRING_AND_TWO_OBJECTS_TO_VOID.equals(signature)) {
return 2;
}
OpcodeStack.... | java | @SuppressWarnings("unchecked")
private int getVarArgsParmCount(String signature) {
if (SignatureBuilder.SIG_STRING_AND_OBJECT_TO_VOID.equals(signature)) {
return 1;
}
if (SIG_STRING_AND_TWO_OBJECTS_TO_VOID.equals(signature)) {
return 2;
}
OpcodeStack.... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"int",
"getVarArgsParmCount",
"(",
"String",
"signature",
")",
"{",
"if",
"(",
"SignatureBuilder",
".",
"SIG_STRING_AND_OBJECT_TO_VOID",
".",
"equals",
"(",
"signature",
")",
")",
"{",
"return",
"1",
... | returns the number of parameters slf4j or log4j2 is expecting to inject into the format string
@param signature
the method signature of the error, warn, info, debug statement
@return the number of expected parameters | [
"returns",
"the",
"number",
"of",
"parameters",
"slf4j",
"or",
"log4j2",
"is",
"expecting",
"to",
"inject",
"into",
"the",
"format",
"string"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java#L628-L646 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java | LoggerOddities.hasExceptionOnStack | @SuppressWarnings("unchecked")
private boolean hasExceptionOnStack() {
try {
for (int i = 0; i < (stack.getStackDepth() - 1); i++) {
OpcodeStack.Item item = stack.getStackItem(i);
String sig = item.getSignature();
if (sig.startsWith(Values.SIG_QUAL... | java | @SuppressWarnings("unchecked")
private boolean hasExceptionOnStack() {
try {
for (int i = 0; i < (stack.getStackDepth() - 1); i++) {
OpcodeStack.Item item = stack.getStackItem(i);
String sig = item.getSignature();
if (sig.startsWith(Values.SIG_QUAL... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"boolean",
"hasExceptionOnStack",
"(",
")",
"{",
"try",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"(",
"stack",
".",
"getStackDepth",
"(",
")",
"-",
"1",
")",
";",
"i",
"++",
... | returns whether an exception object is on the stack slf4j will find this, and not include it in the parm list so i we find one, just don't report
@return whether or not an exception i present | [
"returns",
"whether",
"an",
"exception",
"object",
"is",
"on",
"the",
"stack",
"slf4j",
"will",
"find",
"this",
"and",
"not",
"include",
"it",
"in",
"the",
"parm",
"list",
"so",
"i",
"we",
"find",
"one",
"just",
"don",
"t",
"report"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java#L653-L680 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java | DubiousListCollection.visitClassContext | @Override
public void visitClassContext(final ClassContext classContext) {
JavaClass cls = classContext.getJavaClass();
Field[] flds = cls.getFields();
for (Field f : flds) {
String sig = f.getSignature();
if (sig.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX)) {
if (sig.startsWith("Ljava/util/") && sig... | java | @Override
public void visitClassContext(final ClassContext classContext) {
JavaClass cls = classContext.getJavaClass();
Field[] flds = cls.getFields();
for (Field f : flds) {
String sig = f.getSignature();
if (sig.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX)) {
if (sig.startsWith("Ljava/util/") && sig... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"final",
"ClassContext",
"classContext",
")",
"{",
"JavaClass",
"cls",
"=",
"classContext",
".",
"getJavaClass",
"(",
")",
";",
"Field",
"[",
"]",
"flds",
"=",
"cls",
".",
"getFields",
"(",
")",
... | overrides the visitor to accept classes that define List based fields
@param classContext the context object for the currently parsed class | [
"overrides",
"the",
"visitor",
"to",
"accept",
"classes",
"that",
"define",
"List",
"based",
"fields"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java#L116-L133 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java | DubiousListCollection.visitCode | @Override
public void visitCode(final Code obj) {
try {
stack.resetForMethodEntry(this);
super.visitCode(obj);
} catch (StopOpcodeParsingException e) {
// ok, move on to the next method
}
} | java | @Override
public void visitCode(final Code obj) {
try {
stack.resetForMethodEntry(this);
super.visitCode(obj);
} catch (StopOpcodeParsingException e) {
// ok, move on to the next method
}
} | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"final",
"Code",
"obj",
")",
"{",
"try",
"{",
"stack",
".",
"resetForMethodEntry",
"(",
"this",
")",
";",
"super",
".",
"visitCode",
"(",
"obj",
")",
";",
"}",
"catch",
"(",
"StopOpcodeParsingException",... | overrides the visitor to reset the opcode stack object
@param obj the code object for the currently parse method | [
"overrides",
"the",
"visitor",
"to",
"reset",
"the",
"opcode",
"stack",
"object"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java#L140-L148 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java | DubiousListCollection.sawOpcode | @Override
public void sawOpcode(final int seen) {
try {
stack.precomputation(this);
if (seen == Const.INVOKEINTERFACE) {
processInvokeInterface();
} else if (seen == Const.INVOKEVIRTUAL) {
processInvokeVirtual();
} else if ((seen == Const.ARETURN) && (stack.getStackDepth() > 0)) {
OpcodeStac... | java | @Override
public void sawOpcode(final int seen) {
try {
stack.precomputation(this);
if (seen == Const.INVOKEINTERFACE) {
processInvokeInterface();
} else if (seen == Const.INVOKEVIRTUAL) {
processInvokeVirtual();
} else if ((seen == Const.ARETURN) && (stack.getStackDepth() > 0)) {
OpcodeStac... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"final",
"int",
"seen",
")",
"{",
"try",
"{",
"stack",
".",
"precomputation",
"(",
"this",
")",
";",
"if",
"(",
"seen",
"==",
"Const",
".",
"INVOKEINTERFACE",
")",
"{",
"processInvokeInterface",
"(",
"... | overrides the visitor to record all method calls on List fields. If a method
is not a set based method, remove it from further consideration
@param seen the current opcode parsed. | [
"overrides",
"the",
"visitor",
"to",
"record",
"all",
"method",
"calls",
"on",
"List",
"fields",
".",
"If",
"a",
"method",
"is",
"not",
"a",
"set",
"based",
"method",
"remove",
"it",
"from",
"further",
"consideration"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java#L156-L179 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java | DubiousListCollection.getFieldFromStack | @Nullable
private static XField getFieldFromStack(final OpcodeStack stk, final String signature) {
int parmCount = SignatureUtils.getNumParameters(signature);
if (stk.getStackDepth() > parmCount) {
OpcodeStack.Item itm = stk.getStackItem(parmCount);
return itm.getXField();
}
return null;
} | java | @Nullable
private static XField getFieldFromStack(final OpcodeStack stk, final String signature) {
int parmCount = SignatureUtils.getNumParameters(signature);
if (stk.getStackDepth() > parmCount) {
OpcodeStack.Item itm = stk.getStackItem(parmCount);
return itm.getXField();
}
return null;
} | [
"@",
"Nullable",
"private",
"static",
"XField",
"getFieldFromStack",
"(",
"final",
"OpcodeStack",
"stk",
",",
"final",
"String",
"signature",
")",
"{",
"int",
"parmCount",
"=",
"SignatureUtils",
".",
"getNumParameters",
"(",
"signature",
")",
";",
"if",
"(",
"... | return the field object that the current method was called on, by finding the
reference down in the stack based on the number of parameters
@param stk the opcode stack where fields are stored
@param signature the signature of the called method
@return the field annotation for the field whose method was executed | [
"return",
"the",
"field",
"object",
"that",
"the",
"current",
"method",
"was",
"called",
"on",
"by",
"finding",
"the",
"reference",
"down",
"in",
"the",
"stack",
"based",
"on",
"the",
"number",
"of",
"parameters"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java#L229-L237 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java | DubiousListCollection.reportBugs | private void reportBugs() {
int major = getClassContext().getJavaClass().getMajor();
for (Map.Entry<String, FieldInfo> entry : fieldsReported.entrySet()) {
String field = entry.getKey();
FieldInfo fi = entry.getValue();
int cnt = fi.getSetCount();
if (cnt > 0) {
FieldAnnotation fa = getFieldAnnotati... | java | private void reportBugs() {
int major = getClassContext().getJavaClass().getMajor();
for (Map.Entry<String, FieldInfo> entry : fieldsReported.entrySet()) {
String field = entry.getKey();
FieldInfo fi = entry.getValue();
int cnt = fi.getSetCount();
if (cnt > 0) {
FieldAnnotation fa = getFieldAnnotati... | [
"private",
"void",
"reportBugs",
"(",
")",
"{",
"int",
"major",
"=",
"getClassContext",
"(",
")",
".",
"getJavaClass",
"(",
")",
".",
"getMajor",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"FieldInfo",
">",
"entry",
":",
"fie... | implements the detector, by reporting all remaining fields that only have set
based access | [
"implements",
"the",
"detector",
"by",
"reporting",
"all",
"remaining",
"fields",
"that",
"only",
"have",
"set",
"based",
"access"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java#L243-L259 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java | DubiousListCollection.getFieldAnnotation | @Nullable
private FieldAnnotation getFieldAnnotation(final String fieldName) {
JavaClass cls = getClassContext().getJavaClass();
Field[] fields = cls.getFields();
for (Field f : fields) {
if (f.getName().equals(fieldName)) {
return new FieldAnnotation(cls.getClassName(), fieldName, f.getSignature(), f.isS... | java | @Nullable
private FieldAnnotation getFieldAnnotation(final String fieldName) {
JavaClass cls = getClassContext().getJavaClass();
Field[] fields = cls.getFields();
for (Field f : fields) {
if (f.getName().equals(fieldName)) {
return new FieldAnnotation(cls.getClassName(), fieldName, f.getSignature(), f.isS... | [
"@",
"Nullable",
"private",
"FieldAnnotation",
"getFieldAnnotation",
"(",
"final",
"String",
"fieldName",
")",
"{",
"JavaClass",
"cls",
"=",
"getClassContext",
"(",
")",
".",
"getJavaClass",
"(",
")",
";",
"Field",
"[",
"]",
"fields",
"=",
"cls",
".",
"getFi... | builds a field annotation by finding the field in the classes' field list
@param fieldName the field for which to built the field annotation
@return the field annotation of the specified field | [
"builds",
"a",
"field",
"annotation",
"by",
"finding",
"the",
"field",
"in",
"the",
"classes",
"field",
"list"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java#L268-L278 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ImproperPropertiesUse.java | ImproperPropertiesUse.sawOpcode | @Override
public void sawOpcode(int seen) {
try {
stack.precomputation(this);
if (seen == Const.INVOKEVIRTUAL) {
String clsName = getClassConstantOperand();
if ("java/util/Properties".equals(clsName)) {
String methodName = getNameC... | java | @Override
public void sawOpcode(int seen) {
try {
stack.precomputation(this);
if (seen == Const.INVOKEVIRTUAL) {
String clsName = getClassConstantOperand();
if ("java/util/Properties".equals(clsName)) {
String methodName = getNameC... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"try",
"{",
"stack",
".",
"precomputation",
"(",
"this",
")",
";",
"if",
"(",
"seen",
"==",
"Const",
".",
"INVOKEVIRTUAL",
")",
"{",
"String",
"clsName",
"=",
"getClassConstant... | implements the visitor to look for calls to java.utils.Properties.put, where the value is a non String. Reports both cases, where if it is a string, at a
lower lever.
@param seen
the currently parsed op code | [
"implements",
"the",
"visitor",
"to",
"look",
"for",
"calls",
"to",
"java",
".",
"utils",
".",
"Properties",
".",
"put",
"where",
"the",
"value",
"is",
"a",
"non",
"String",
".",
"Reports",
"both",
"cases",
"where",
"if",
"it",
"is",
"a",
"string",
"at... | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ImproperPropertiesUse.java#L90-L121 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java | BogusExceptionDeclaration.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
try {
if ((runtimeExceptionClass != null) && (exceptionClass != null)) {
stack = new OpcodeStack();
declaredCheckedExceptions = new HashSet<>(6);
JavaClass cls = classContext.getJ... | java | @Override
public void visitClassContext(ClassContext classContext) {
try {
if ((runtimeExceptionClass != null) && (exceptionClass != null)) {
stack = new OpcodeStack();
declaredCheckedExceptions = new HashSet<>(6);
JavaClass cls = classContext.getJ... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"try",
"{",
"if",
"(",
"(",
"runtimeExceptionClass",
"!=",
"null",
")",
"&&",
"(",
"exceptionClass",
"!=",
"null",
")",
")",
"{",
"stack",
"=",
"new",
"O... | overrides the visitor to create the opcode stack
@param classContext
the context object of the currently parsed class | [
"overrides",
"the",
"visitor",
"to",
"create",
"the",
"opcode",
"stack"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java#L89-L104 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java | BogusExceptionDeclaration.visitCode | @Override
public void visitCode(Code obj) {
Method method = getMethod();
if (method.isSynthetic()) {
return;
}
declaredCheckedExceptions.clear();
stack.resetForMethodEntry(this);
ExceptionTable et = method.getExceptionTable();
if (et != null) {
... | java | @Override
public void visitCode(Code obj) {
Method method = getMethod();
if (method.isSynthetic()) {
return;
}
declaredCheckedExceptions.clear();
stack.resetForMethodEntry(this);
ExceptionTable et = method.getExceptionTable();
if (et != null) {
... | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"Method",
"method",
"=",
"getMethod",
"(",
")",
";",
"if",
"(",
"method",
".",
"isSynthetic",
"(",
")",
")",
"{",
"return",
";",
"}",
"declaredCheckedExceptions",
".",
"clear",... | implements the visitor to see if the method declares that it throws any checked exceptions.
@param obj
the context object of the currently parsed code block | [
"implements",
"the",
"visitor",
"to",
"see",
"if",
"the",
"method",
"declares",
"that",
"it",
"throws",
"any",
"checked",
"exceptions",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java#L112-L185 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java | BogusExceptionDeclaration.sawOpcode | @Override
public void sawOpcode(int seen) {
try {
stack.precomputation(this);
if (OpcodeUtils.isStandardInvoke(seen)) {
String clsName = getClassConstantOperand();
if (!safeClasses.contains(clsName)) {
try {
... | java | @Override
public void sawOpcode(int seen) {
try {
stack.precomputation(this);
if (OpcodeUtils.isStandardInvoke(seen)) {
String clsName = getClassConstantOperand();
if (!safeClasses.contains(clsName)) {
try {
... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"try",
"{",
"stack",
".",
"precomputation",
"(",
"this",
")",
";",
"if",
"(",
"OpcodeUtils",
".",
"isStandardInvoke",
"(",
"seen",
")",
")",
"{",
"String",
"clsName",
"=",
"g... | implements the visitor to look for method calls that could throw the exceptions that are listed in the declaration. | [
"implements",
"the",
"visitor",
"to",
"look",
"for",
"method",
"calls",
"that",
"could",
"throw",
"the",
"exceptions",
"that",
"are",
"listed",
"in",
"the",
"declaration",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java#L204-L263 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java | BogusExceptionDeclaration.removeThrownExceptionHierarchy | private void removeThrownExceptionHierarchy(String thrownException) {
try {
if (Values.DOTTED_JAVA_LANG_EXCEPTION.equals(thrownException) || Values.DOTTED_JAVA_LANG_THROWABLE.equals(thrownException)) {
// Exception/Throwable can be thrown even tho the method isn't declared to throw
... | java | private void removeThrownExceptionHierarchy(String thrownException) {
try {
if (Values.DOTTED_JAVA_LANG_EXCEPTION.equals(thrownException) || Values.DOTTED_JAVA_LANG_THROWABLE.equals(thrownException)) {
// Exception/Throwable can be thrown even tho the method isn't declared to throw
... | [
"private",
"void",
"removeThrownExceptionHierarchy",
"(",
"String",
"thrownException",
")",
"{",
"try",
"{",
"if",
"(",
"Values",
".",
"DOTTED_JAVA_LANG_EXCEPTION",
".",
"equals",
"(",
"thrownException",
")",
"||",
"Values",
".",
"DOTTED_JAVA_LANG_THROWABLE",
".",
"... | removes this thrown exception the list of declared thrown exceptions, including all exceptions in this exception's hierarchy. If an exception class is
found that can't be loaded, then just clear the list of declared checked exceptions and get out.
@param thrownException
the exception and it's hierarchy to remove | [
"removes",
"this",
"thrown",
"exception",
"the",
"list",
"of",
"declared",
"thrown",
"exceptions",
"including",
"all",
"exceptions",
"in",
"this",
"exception",
"s",
"hierarchy",
".",
"If",
"an",
"exception",
"class",
"is",
"found",
"that",
"can",
"t",
"be",
... | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java#L272-L298 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java | NeedlessCustomSerialization.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
try {
JavaClass cls = classContext.getJavaClass();
if ((serializableClass != null) && cls.implementationOf(serializableClass)) {
super.visitClassContext(classContext);
}
} catch (... | java | @Override
public void visitClassContext(ClassContext classContext) {
try {
JavaClass cls = classContext.getJavaClass();
if ((serializableClass != null) && cls.implementationOf(serializableClass)) {
super.visitClassContext(classContext);
}
} catch (... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"try",
"{",
"JavaClass",
"cls",
"=",
"classContext",
".",
"getJavaClass",
"(",
")",
";",
"if",
"(",
"(",
"serializableClass",
"!=",
"null",
")",
"&&",
"cls... | overrides the method to check for Serializable | [
"overrides",
"the",
"method",
"to",
"check",
"for",
"Serializable"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java#L72-L82 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java | NeedlessCustomSerialization.visitCode | @Override
public void visitCode(Code obj) {
String nameAndSignature = getMethod().getName() + getMethod().getSignature();
if (SignatureBuilder.SIG_READ_OBJECT.equals(nameAndSignature)) {
inReadObject = true;
inWriteObject = false;
} else if (SIG_WRITE_OBJECT.equals(na... | java | @Override
public void visitCode(Code obj) {
String nameAndSignature = getMethod().getName() + getMethod().getSignature();
if (SignatureBuilder.SIG_READ_OBJECT.equals(nameAndSignature)) {
inReadObject = true;
inWriteObject = false;
} else if (SIG_WRITE_OBJECT.equals(na... | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"String",
"nameAndSignature",
"=",
"getMethod",
"(",
")",
".",
"getName",
"(",
")",
"+",
"getMethod",
"(",
")",
".",
"getSignature",
"(",
")",
";",
"if",
"(",
"SignatureBuilder... | overrides the method to check for either readObject or writeObject methods and if so, reset the stack | [
"overrides",
"the",
"method",
"to",
"check",
"for",
"either",
"readObject",
"or",
"writeObject",
"methods",
"and",
"if",
"so",
"reset",
"the",
"stack"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java#L87-L106 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/IOIssues.java | IOIssues.visitClassContext | @Override
public void visitClassContext(ClassContext clsContext) {
try {
stack = new OpcodeStack();
clsVersion = clsContext.getJavaClass().getMajor();
unendedZLIBs = new HashMap<>();
super.visitClassContext(clsContext);
} finally {
unended... | java | @Override
public void visitClassContext(ClassContext clsContext) {
try {
stack = new OpcodeStack();
clsVersion = clsContext.getJavaClass().getMajor();
unendedZLIBs = new HashMap<>();
super.visitClassContext(clsContext);
} finally {
unended... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"clsContext",
")",
"{",
"try",
"{",
"stack",
"=",
"new",
"OpcodeStack",
"(",
")",
";",
"clsVersion",
"=",
"clsContext",
".",
"getJavaClass",
"(",
")",
".",
"getMajor",
"(",
")",
"... | implements the visitor to create and tear down the opcode stack
@param clsContext the context object of the currently parsed class | [
"implements",
"the",
"visitor",
"to",
"create",
"and",
"tear",
"down",
"the",
"opcode",
"stack"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/IOIssues.java#L110-L122 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java | OverlyConcreteParameter.visitMethod | @Override
public void visitMethod(Method obj) {
methodSignatureIsConstrained = false;
String methodName = obj.getName();
if (!Values.CONSTRUCTOR.equals(methodName) && !Values.STATIC_INITIALIZER.equals(methodName)) {
String methodSig = obj.getSignature();
methodSign... | java | @Override
public void visitMethod(Method obj) {
methodSignatureIsConstrained = false;
String methodName = obj.getName();
if (!Values.CONSTRUCTOR.equals(methodName) && !Values.STATIC_INITIALIZER.equals(methodName)) {
String methodSig = obj.getSignature();
methodSign... | [
"@",
"Override",
"public",
"void",
"visitMethod",
"(",
"Method",
"obj",
")",
"{",
"methodSignatureIsConstrained",
"=",
"false",
";",
"String",
"methodName",
"=",
"obj",
".",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"Values",
".",
"CONSTRUCTOR",
".",
"equa... | implements the visitor to look to see if this method is constrained by a
superclass or interface.
@param obj the currently parsed method | [
"implements",
"the",
"visitor",
"to",
"look",
"to",
"see",
"if",
"this",
"method",
"is",
"constrained",
"by",
"a",
"superclass",
"or",
"interface",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java#L139-L175 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java | OverlyConcreteParameter.visitCode | @Override
public void visitCode(final Code obj) {
try {
if (methodSignatureIsConstrained) {
return;
}
if (obj.getCode() == null) {
return;
}
Method m = getMethod();
if (m.isSynthetic()) {
... | java | @Override
public void visitCode(final Code obj) {
try {
if (methodSignatureIsConstrained) {
return;
}
if (obj.getCode() == null) {
return;
}
Method m = getMethod();
if (m.isSynthetic()) {
... | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"final",
"Code",
"obj",
")",
"{",
"try",
"{",
"if",
"(",
"methodSignatureIsConstrained",
")",
"{",
"return",
";",
"}",
"if",
"(",
"obj",
".",
"getCode",
"(",
")",
"==",
"null",
")",
"{",
"return",
... | implements the visitor to collect information about the parameters of a this
method
@param obj the currently parsed code block | [
"implements",
"the",
"visitor",
"to",
"collect",
"information",
"about",
"the",
"parameters",
"of",
"a",
"this",
"method"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java#L183-L225 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java | OverlyConcreteParameter.methodIsSpecial | private static boolean methodIsSpecial(String methodName, String methodSig) {
return SignatureBuilder.SIG_READ_OBJECT.equals(methodName + methodSig);
} | java | private static boolean methodIsSpecial(String methodName, String methodSig) {
return SignatureBuilder.SIG_READ_OBJECT.equals(methodName + methodSig);
} | [
"private",
"static",
"boolean",
"methodIsSpecial",
"(",
"String",
"methodName",
",",
"String",
"methodSig",
")",
"{",
"return",
"SignatureBuilder",
".",
"SIG_READ_OBJECT",
".",
"equals",
"(",
"methodName",
"+",
"methodSig",
")",
";",
"}"
] | determines whether the method is a baked in special method of the jdk
@param methodName the method name to check
@param methodSig the parameter signature of the method to check
@return if it is a well known baked in method | [
"determines",
"whether",
"the",
"method",
"is",
"a",
"baked",
"in",
"special",
"method",
"of",
"the",
"jdk"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java#L357-L359 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java | OverlyConcreteParameter.methodHasSyntheticTwin | private boolean methodHasSyntheticTwin(String methodName, String methodSig) {
for (Method m : cls.getMethods()) {
if (m.isSynthetic() && m.getName().equals(methodName) && !m.getSignature().equals(methodSig)) {
return true;
}
}
return false;
} | java | private boolean methodHasSyntheticTwin(String methodName, String methodSig) {
for (Method m : cls.getMethods()) {
if (m.isSynthetic() && m.getName().equals(methodName) && !m.getSignature().equals(methodSig)) {
return true;
}
}
return false;
} | [
"private",
"boolean",
"methodHasSyntheticTwin",
"(",
"String",
"methodName",
",",
"String",
"methodSig",
")",
"{",
"for",
"(",
"Method",
"m",
":",
"cls",
".",
"getMethods",
"(",
")",
")",
"{",
"if",
"(",
"m",
".",
"isSynthetic",
"(",
")",
"&&",
"m",
".... | returns whether this method has an equivalent method that is synthetic, which
implies this method is constrained by some Generified interface. We could
compare parameters but that is a bunch of work that probably doesn't make
this test any more precise, so just return true if method name and synthetic
is found.
@param... | [
"returns",
"whether",
"this",
"method",
"has",
"an",
"equivalent",
"method",
"that",
"is",
"synthetic",
"which",
"implies",
"this",
"method",
"is",
"constrained",
"by",
"some",
"Generified",
"interface",
".",
"We",
"could",
"compare",
"parameters",
"but",
"that"... | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java#L372-L380 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java | OverlyConcreteParameter.reportBugs | private void reportBugs() {
Iterator<Map.Entry<Integer, Map<JavaClass, List<MethodInfo>>>> it = parameterDefiners.entrySet().iterator();
while (it.hasNext()) {
try {
Map.Entry<Integer, Map<JavaClass, List<MethodInfo>>> entry = it.next();
Integer reg = entry.g... | java | private void reportBugs() {
Iterator<Map.Entry<Integer, Map<JavaClass, List<MethodInfo>>>> it = parameterDefiners.entrySet().iterator();
while (it.hasNext()) {
try {
Map.Entry<Integer, Map<JavaClass, List<MethodInfo>>> entry = it.next();
Integer reg = entry.g... | [
"private",
"void",
"reportBugs",
"(",
")",
"{",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"Map",
"<",
"JavaClass",
",",
"List",
"<",
"MethodInfo",
">",
">",
">",
">",
"it",
"=",
"parameterDefiners",
".",
"entrySet",
"(",
")",
".",
"i... | implements the post processing steps to report the remaining unremoved
parameter definers, ie those, that can be defined more abstractly. | [
"implements",
"the",
"post",
"processing",
"steps",
"to",
"report",
"the",
"remaining",
"unremoved",
"parameter",
"definers",
"ie",
"those",
"that",
"can",
"be",
"defined",
"more",
"abstractly",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java#L386-L431 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java | OverlyConcreteParameter.hasOverloadedMethod | private boolean hasOverloadedMethod() {
Method thisMethod = getMethod();
String name = thisMethod.getName();
String sig = thisMethod.getSignature();
int numArgs = SignatureUtils.getNumParameters(sig);
for (Method m : cls.getMethods()) {
if (m.getName().equals(name)) ... | java | private boolean hasOverloadedMethod() {
Method thisMethod = getMethod();
String name = thisMethod.getName();
String sig = thisMethod.getSignature();
int numArgs = SignatureUtils.getNumParameters(sig);
for (Method m : cls.getMethods()) {
if (m.getName().equals(name)) ... | [
"private",
"boolean",
"hasOverloadedMethod",
"(",
")",
"{",
"Method",
"thisMethod",
"=",
"getMethod",
"(",
")",
";",
"String",
"name",
"=",
"thisMethod",
".",
"getName",
"(",
")",
";",
"String",
"sig",
"=",
"thisMethod",
".",
"getSignature",
"(",
")",
";",... | looks to see if this method has an overloaded method in actuality, this isn't
precise and returns true for methods that are named the same, and have same
number of args This will miss some cases, but in practicality doesn't matter.
@return whether there is a method in this class that overrides the given
method | [
"looks",
"to",
"see",
"if",
"this",
"method",
"has",
"an",
"overloaded",
"method",
"in",
"actuality",
"this",
"isn",
"t",
"precise",
"and",
"returns",
"true",
"for",
"methods",
"that",
"are",
"named",
"the",
"same",
"and",
"have",
"same",
"number",
"of",
... | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java#L441-L455 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java | OverlyConcreteParameter.buildParameterDefiners | private boolean buildParameterDefiners() throws ClassNotFoundException {
Method m = getMethod();
Type[] parms = m.getArgumentTypes();
if (parms.length == 0) {
return false;
}
ParameterAnnotationEntry[] annotations = m.getParameterAnnotationEntries();
boole... | java | private boolean buildParameterDefiners() throws ClassNotFoundException {
Method m = getMethod();
Type[] parms = m.getArgumentTypes();
if (parms.length == 0) {
return false;
}
ParameterAnnotationEntry[] annotations = m.getParameterAnnotationEntries();
boole... | [
"private",
"boolean",
"buildParameterDefiners",
"(",
")",
"throws",
"ClassNotFoundException",
"{",
"Method",
"m",
"=",
"getMethod",
"(",
")",
";",
"Type",
"[",
"]",
"parms",
"=",
"m",
".",
"getArgumentTypes",
"(",
")",
";",
"if",
"(",
"parms",
".",
"length... | builds a map of method information for each method of each interface that
each parameter implements of this method
@return a map by parameter id of all the method signatures that interfaces of
that parameter implements
@throws ClassNotFoundException if the class can't be loaded | [
"builds",
"a",
"map",
"of",
"method",
"information",
"for",
"each",
"method",
"of",
"each",
"interface",
"that",
"each",
"parameter",
"implements",
"of",
"this",
"method"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java#L509-L547 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java | OverlyConcreteParameter.getClassDefiners | private static Map<JavaClass, List<MethodInfo>> getClassDefiners(final JavaClass cls)
throws ClassNotFoundException {
Map<JavaClass, List<MethodInfo>> definers = new HashMap<>();
for (JavaClass ci : cls.getAllInterfaces()) {
if (cls.equals(ci) || !cls.isPublic() || "java.lang.Co... | java | private static Map<JavaClass, List<MethodInfo>> getClassDefiners(final JavaClass cls)
throws ClassNotFoundException {
Map<JavaClass, List<MethodInfo>> definers = new HashMap<>();
for (JavaClass ci : cls.getAllInterfaces()) {
if (cls.equals(ci) || !cls.isPublic() || "java.lang.Co... | [
"private",
"static",
"Map",
"<",
"JavaClass",
",",
"List",
"<",
"MethodInfo",
">",
">",
"getClassDefiners",
"(",
"final",
"JavaClass",
"cls",
")",
"throws",
"ClassNotFoundException",
"{",
"Map",
"<",
"JavaClass",
",",
"List",
"<",
"MethodInfo",
">",
">",
"de... | returns a map of method information for each public method for each interface
this class implements
@param cls the class whose interfaces to record
@return a map of (method name)(method sig) by interface
@throws ClassNotFoundException if unable to load the class | [
"returns",
"a",
"map",
"of",
"method",
"information",
"for",
"each",
"public",
"method",
"for",
"each",
"interface",
"this",
"class",
"implements"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java#L558-L572 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java | OverlyConcreteParameter.getPublicMethodInfos | private static List<MethodInfo> getPublicMethodInfos(final JavaClass cls) {
List<MethodInfo> methodInfos = new ArrayList<>();
Method[] methods = cls.getMethods();
for (Method m : methods) {
if ((m.getAccessFlags() & (Const.ACC_PUBLIC | Const.ACC_PROTECTED)) != 0) {
Ex... | java | private static List<MethodInfo> getPublicMethodInfos(final JavaClass cls) {
List<MethodInfo> methodInfos = new ArrayList<>();
Method[] methods = cls.getMethods();
for (Method m : methods) {
if ((m.getAccessFlags() & (Const.ACC_PUBLIC | Const.ACC_PROTECTED)) != 0) {
Ex... | [
"private",
"static",
"List",
"<",
"MethodInfo",
">",
"getPublicMethodInfos",
"(",
"final",
"JavaClass",
"cls",
")",
"{",
"List",
"<",
"MethodInfo",
">",
"methodInfos",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Method",
"[",
"]",
"methods",
"=",
"cls",... | returns a list of method information of all public or protected methods in
this class
@param cls the class to look for methods
@return a map of (method name)(method signature) | [
"returns",
"a",
"list",
"of",
"method",
"information",
"of",
"all",
"public",
"or",
"protected",
"methods",
"in",
"this",
"class"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java#L581-L592 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java | OverlyConcreteParameter.removeUselessDefiners | private void removeUselessDefiners(final int reg) {
Map<JavaClass, List<MethodInfo>> definers = parameterDefiners.get(Integer.valueOf(reg));
if (CollectionUtils.isEmpty(definers)) {
return;
}
String methodSig = getSigConstantOperand();
String methodName = getNameCons... | java | private void removeUselessDefiners(final int reg) {
Map<JavaClass, List<MethodInfo>> definers = parameterDefiners.get(Integer.valueOf(reg));
if (CollectionUtils.isEmpty(definers)) {
return;
}
String methodSig = getSigConstantOperand();
String methodName = getNameCons... | [
"private",
"void",
"removeUselessDefiners",
"(",
"final",
"int",
"reg",
")",
"{",
"Map",
"<",
"JavaClass",
",",
"List",
"<",
"MethodInfo",
">",
">",
"definers",
"=",
"parameterDefiners",
".",
"get",
"(",
"Integer",
".",
"valueOf",
"(",
"reg",
")",
")",
"... | parses through the interface that 'may' define a parameter defined by reg,
and look to see if we can rule it out, because a method is called on the
object that can't be satisfied by the interface, if so remove that candidate
interface.
@param reg the parameter register number to look at | [
"parses",
"through",
"the",
"interface",
"that",
"may",
"define",
"a",
"parameter",
"defined",
"by",
"reg",
"and",
"look",
"to",
"see",
"if",
"we",
"can",
"rule",
"it",
"out",
"because",
"a",
"method",
"is",
"called",
"on",
"the",
"object",
"that",
"can"... | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java#L602-L639 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java | OverlyConcreteParameter.isaConversionClass | private boolean isaConversionClass(JavaClass conversionCls) {
for (AnnotationEntry entry : conversionCls.getAnnotationEntries()) {
if (CONVERSION_ANNOTATIONS.contains(entry.getAnnotationType())) {
return true;
}
// this ignores the fact that this class might ... | java | private boolean isaConversionClass(JavaClass conversionCls) {
for (AnnotationEntry entry : conversionCls.getAnnotationEntries()) {
if (CONVERSION_ANNOTATIONS.contains(entry.getAnnotationType())) {
return true;
}
// this ignores the fact that this class might ... | [
"private",
"boolean",
"isaConversionClass",
"(",
"JavaClass",
"conversionCls",
")",
"{",
"for",
"(",
"AnnotationEntry",
"entry",
":",
"conversionCls",
".",
"getAnnotationEntries",
"(",
")",
")",
"{",
"if",
"(",
"CONVERSION_ANNOTATIONS",
".",
"contains",
"(",
"entr... | returns whether this class is used to convert types of some sort, such that
you don't want to suggest reducing the class specified to be more generic
@param conversionCls the class to check
@return whether this class is used in conversions | [
"returns",
"whether",
"this",
"class",
"is",
"used",
"to",
"convert",
"types",
"of",
"some",
"sort",
"such",
"that",
"you",
"don",
"t",
"want",
"to",
"suggest",
"reducing",
"the",
"class",
"specified",
"to",
"be",
"more",
"generic"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java#L720-L733 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java | ListIndexedIterating.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
try {
stack = new OpcodeStack();
possibleForLoops = new HashSet<>();
super.visitClassContext(classContext);
} finally {
stack = null;
possibleForLoops = null;
}
... | java | @Override
public void visitClassContext(ClassContext classContext) {
try {
stack = new OpcodeStack();
possibleForLoops = new HashSet<>();
super.visitClassContext(classContext);
} finally {
stack = null;
possibleForLoops = null;
}
... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"try",
"{",
"stack",
"=",
"new",
"OpcodeStack",
"(",
")",
";",
"possibleForLoops",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"super",
".",
"visitClassCon... | overrides the interface to create and clear the stack and loops tracker
@param classContext
the context object for the currently parsed class | [
"overrides",
"the",
"interface",
"to",
"create",
"and",
"clear",
"the",
"stack",
"and",
"loops",
"tracker"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java#L84-L94 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java | ListIndexedIterating.prescreen | private boolean prescreen(Method method) {
BitSet bytecodeSet = getClassContext().getBytecodeSet(method);
return (bytecodeSet != null) && (bytecodeSet.get(Const.IINC)) && (bytecodeSet.get(Const.GOTO) || bytecodeSet.get(Const.GOTO_W));
} | java | private boolean prescreen(Method method) {
BitSet bytecodeSet = getClassContext().getBytecodeSet(method);
return (bytecodeSet != null) && (bytecodeSet.get(Const.IINC)) && (bytecodeSet.get(Const.GOTO) || bytecodeSet.get(Const.GOTO_W));
} | [
"private",
"boolean",
"prescreen",
"(",
"Method",
"method",
")",
"{",
"BitSet",
"bytecodeSet",
"=",
"getClassContext",
"(",
")",
".",
"getBytecodeSet",
"(",
"method",
")",
";",
"return",
"(",
"bytecodeSet",
"!=",
"null",
")",
"&&",
"(",
"bytecodeSet",
".",
... | looks for methods that contain a IINC and GOTO or GOTO_W opcodes
@param method
the context object of the current method
@return if the class uses synchronization | [
"looks",
"for",
"methods",
"that",
"contain",
"a",
"IINC",
"and",
"GOTO",
"or",
"GOTO_W",
"opcodes"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java#L103-L106 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java | ListIndexedIterating.visitCode | @Override
public void visitCode(final Code obj) {
Method m = getMethod();
if (prescreen(m)) {
sawListSize = false;
stack.resetForMethodEntry(this);
state = State.SAW_NOTHING;
stage = Stage.FIND_LOOP_STAGE;
super.visitCode(obj);
... | java | @Override
public void visitCode(final Code obj) {
Method m = getMethod();
if (prescreen(m)) {
sawListSize = false;
stack.resetForMethodEntry(this);
state = State.SAW_NOTHING;
stage = Stage.FIND_LOOP_STAGE;
super.visitCode(obj);
... | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"final",
"Code",
"obj",
")",
"{",
"Method",
"m",
"=",
"getMethod",
"(",
")",
";",
"if",
"(",
"prescreen",
"(",
"m",
")",
")",
"{",
"sawListSize",
"=",
"false",
";",
"stack",
".",
"resetForMethodEntry... | overrides the visitor to reset the opcode stack
@param obj
the code object for the currently parsed Code | [
"overrides",
"the",
"visitor",
"to",
"reset",
"the",
"opcode",
"stack"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java#L114-L132 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java | ListIndexedIterating.sawOpcode | @Override
public void sawOpcode(final int seen) {
if (stage == Stage.FIND_LOOP_STAGE) {
sawOpcodeLoop(seen);
} else {
sawOpcodeBug(seen);
}
} | java | @Override
public void sawOpcode(final int seen) {
if (stage == Stage.FIND_LOOP_STAGE) {
sawOpcodeLoop(seen);
} else {
sawOpcodeBug(seen);
}
} | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"final",
"int",
"seen",
")",
"{",
"if",
"(",
"stage",
"==",
"Stage",
".",
"FIND_LOOP_STAGE",
")",
"{",
"sawOpcodeLoop",
"(",
"seen",
")",
";",
"}",
"else",
"{",
"sawOpcodeBug",
"(",
"seen",
")",
";",... | overrides the visitor to find list indexed iterating
@param seen
the currently parsed opcode | [
"overrides",
"the",
"visitor",
"to",
"find",
"list",
"indexed",
"iterating"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java#L140-L147 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java | ListIndexedIterating.sawOpcodeLoop | private void sawOpcodeLoop(final int seen) {
try {
stack.mergeJumps(this);
switch (state) {
case SAW_NOTHING:
if ((seen == Const.IINC) && (getIntConstant() == 1)) {
loopReg = getRegisterOperand();
state ... | java | private void sawOpcodeLoop(final int seen) {
try {
stack.mergeJumps(this);
switch (state) {
case SAW_NOTHING:
if ((seen == Const.IINC) && (getIntConstant() == 1)) {
loopReg = getRegisterOperand();
state ... | [
"private",
"void",
"sawOpcodeLoop",
"(",
"final",
"int",
"seen",
")",
"{",
"try",
"{",
"stack",
".",
"mergeJumps",
"(",
"this",
")",
";",
"switch",
"(",
"state",
")",
"{",
"case",
"SAW_NOTHING",
":",
"if",
"(",
"(",
"seen",
"==",
"Const",
".",
"IINC"... | the first pass of the method opcode to collet for loops information
@param seen
the currently parsed opcode | [
"the",
"first",
"pass",
"of",
"the",
"method",
"opcode",
"to",
"collet",
"for",
"loops",
"information"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java#L155-L186 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java | NonRecycleableTaglibs.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
try {
JavaClass cls = classContext.getJavaClass();
JavaClass[] superClasses = cls.getSuperClasses();
for (JavaClass superCls : superClasses) {
if (tagClasses.contains(superCls.getClassNam... | java | @Override
public void visitClassContext(ClassContext classContext) {
try {
JavaClass cls = classContext.getJavaClass();
JavaClass[] superClasses = cls.getSuperClasses();
for (JavaClass superCls : superClasses) {
if (tagClasses.contains(superCls.getClassNam... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"try",
"{",
"JavaClass",
"cls",
"=",
"classContext",
".",
"getJavaClass",
"(",
")",
";",
"JavaClass",
"[",
"]",
"superClasses",
"=",
"cls",
".",
"getSuperCla... | implements the visitor to look for classes that extend the TagSupport or BodyTagSupport class
@param classContext
the context object for the currently parsed class | [
"implements",
"the",
"visitor",
"to",
"look",
"for",
"classes",
"that",
"extend",
"the",
"TagSupport",
"or",
"BodyTagSupport",
"class"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java#L85-L111 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java | NonRecycleableTaglibs.getAttributes | private static Map<QMethod, String> getAttributes(JavaClass cls) {
Map<QMethod, String> atts = new HashMap<>();
Method[] methods = cls.getMethods();
for (Method m : methods) {
String name = m.getName();
if (name.startsWith("set") && m.isPublic() && !m.isStatic()) {
... | java | private static Map<QMethod, String> getAttributes(JavaClass cls) {
Map<QMethod, String> atts = new HashMap<>();
Method[] methods = cls.getMethods();
for (Method m : methods) {
String name = m.getName();
if (name.startsWith("set") && m.isPublic() && !m.isStatic()) {
... | [
"private",
"static",
"Map",
"<",
"QMethod",
",",
"String",
">",
"getAttributes",
"(",
"JavaClass",
"cls",
")",
"{",
"Map",
"<",
"QMethod",
",",
"String",
">",
"atts",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Method",
"[",
"]",
"methods",
"=",
"cl... | collect all possible attributes given the name of methods available.
@param cls
the class to look for setter methods to infer properties
@return the map of possible attributes/types | [
"collect",
"all",
"possible",
"attributes",
"given",
"the",
"name",
"of",
"methods",
"available",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java#L120-L140 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java | NonRecycleableTaglibs.visitCode | @Override
public void visitCode(Code obj) {
Method m = getMethod();
if (!Values.CONSTRUCTOR.equals(m.getName())) {
super.visitCode(obj);
}
} | java | @Override
public void visitCode(Code obj) {
Method m = getMethod();
if (!Values.CONSTRUCTOR.equals(m.getName())) {
super.visitCode(obj);
}
} | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"Method",
"m",
"=",
"getMethod",
"(",
")",
";",
"if",
"(",
"!",
"Values",
".",
"CONSTRUCTOR",
".",
"equals",
"(",
"m",
".",
"getName",
"(",
")",
")",
")",
"{",
"super",
... | implements the visitor to
@param obj
the context object for the currently parsed code object | [
"implements",
"the",
"visitor",
"to"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java#L148-L154 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java | NonRecycleableTaglibs.sawOpcode | @Override
public void sawOpcode(int seen) {
if (seen == Const.PUTFIELD) {
QMethod methodInfo = new QMethod(getMethodName(), getMethodSig());
Map<Map.Entry<String, String>, SourceLineAnnotation> fields = methodWrites.get(methodInfo);
if (fields == null) {
f... | java | @Override
public void sawOpcode(int seen) {
if (seen == Const.PUTFIELD) {
QMethod methodInfo = new QMethod(getMethodName(), getMethodSig());
Map<Map.Entry<String, String>, SourceLineAnnotation> fields = methodWrites.get(methodInfo);
if (fields == null) {
f... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"if",
"(",
"seen",
"==",
"Const",
".",
"PUTFIELD",
")",
"{",
"QMethod",
"methodInfo",
"=",
"new",
"QMethod",
"(",
"getMethodName",
"(",
")",
",",
"getMethodSig",
"(",
")",
")... | implements the visitor to record storing of fields, and where they occur
@param seen
the currently parsed opcode | [
"implements",
"the",
"visitor",
"to",
"record",
"storing",
"of",
"fields",
"and",
"where",
"they",
"occur"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java#L162-L178 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java | NonRecycleableTaglibs.reportBugs | private void reportBugs() {
for (Map.Entry<QMethod, String> attEntry : attributes.entrySet()) {
QMethod methodInfo = attEntry.getKey();
String attType = attEntry.getValue();
Map<Map.Entry<String, String>, SourceLineAnnotation> fields = methodWrites.get(methodInfo);
... | java | private void reportBugs() {
for (Map.Entry<QMethod, String> attEntry : attributes.entrySet()) {
QMethod methodInfo = attEntry.getKey();
String attType = attEntry.getValue();
Map<Map.Entry<String, String>, SourceLineAnnotation> fields = methodWrites.get(methodInfo);
... | [
"private",
"void",
"reportBugs",
"(",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"QMethod",
",",
"String",
">",
"attEntry",
":",
"attributes",
".",
"entrySet",
"(",
")",
")",
"{",
"QMethod",
"methodInfo",
"=",
"attEntry",
".",
"getKey",
"(",
")",
... | generates all the bug reports for attributes that are not recycleable | [
"generates",
"all",
"the",
"bug",
"reports",
"for",
"attributes",
"that",
"are",
"not",
"recycleable"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java#L183-L215 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java | SpoiledChildInterfaceImplementor.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
try {
JavaClass cls = classContext.getJavaClass();
if (cls.isAbstract() || cls.isInterface()) {
return;
}
if (Values.DOTTED_JAVA_LANG_OBJECT.equals(cls.getSuperclassName()))... | java | @Override
public void visitClassContext(ClassContext classContext) {
try {
JavaClass cls = classContext.getJavaClass();
if (cls.isAbstract() || cls.isInterface()) {
return;
}
if (Values.DOTTED_JAVA_LANG_OBJECT.equals(cls.getSuperclassName()))... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"try",
"{",
"JavaClass",
"cls",
"=",
"classContext",
".",
"getJavaClass",
"(",
")",
";",
"if",
"(",
"cls",
".",
"isAbstract",
"(",
")",
"||",
"cls",
".",... | looks for classes that implement interfaces but don't provide those methods
@param classContext
the context object of the currently parsed class | [
"looks",
"for",
"classes",
"that",
"implement",
"interfaces",
"but",
"don",
"t",
"provide",
"those",
"methods"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java#L79-L122 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java | SpoiledChildInterfaceImplementor.filterSuperInterfaceMethods | private void filterSuperInterfaceMethods(JavaClass inf, Set<QMethod> infMethods, JavaClass cls) {
try {
if (infMethods.isEmpty()) {
return;
}
JavaClass[] superInfs = inf.getInterfaces();
for (JavaClass superInf : superInfs) {
if (c... | java | private void filterSuperInterfaceMethods(JavaClass inf, Set<QMethod> infMethods, JavaClass cls) {
try {
if (infMethods.isEmpty()) {
return;
}
JavaClass[] superInfs = inf.getInterfaces();
for (JavaClass superInf : superInfs) {
if (c... | [
"private",
"void",
"filterSuperInterfaceMethods",
"(",
"JavaClass",
"inf",
",",
"Set",
"<",
"QMethod",
">",
"infMethods",
",",
"JavaClass",
"cls",
")",
"{",
"try",
"{",
"if",
"(",
"infMethods",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"Jav... | removes methods found in an interface when a super interface having the same methods is implemented in a parent. While this is somewhat hinky, we'll
allow it.
@param inf
the interface to look for super interfaces for
@param infMethods
the remaining methods that are needed to be found
@param cls
the super class to look... | [
"removes",
"methods",
"found",
"in",
"an",
"interface",
"when",
"a",
"super",
"interface",
"having",
"the",
"same",
"methods",
"is",
"implemented",
"in",
"a",
"parent",
".",
"While",
"this",
"is",
"somewhat",
"hinky",
"we",
"ll",
"allow",
"it",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java#L182-L203 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UseAddAll.java | UseAddAll.visitCode | @Override
public void visitCode(Code obj) {
try {
userValues = new HashMap<>();
loops = new HashMap<>();
isInstanceMethod = !getMethod().isStatic();
super.visitCode(obj);
} finally {
userValues = null;
loops = null;
}
... | java | @Override
public void visitCode(Code obj) {
try {
userValues = new HashMap<>();
loops = new HashMap<>();
isInstanceMethod = !getMethod().isStatic();
super.visitCode(obj);
} finally {
userValues = null;
loops = null;
}
... | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"try",
"{",
"userValues",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"loops",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"isInstanceMethod",
"=",
"!",
"getMethod",
"(",
"... | implements the visitor to reset the userValues and loops
@param obj
the context object of the currently parsed code block | [
"implements",
"the",
"visitor",
"to",
"reset",
"the",
"userValues",
"and",
"loops"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UseAddAll.java#L75-L86 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UseAddAll.java | UseAddAll.isFieldCollection | @Nullable
private String isFieldCollection(OpcodeStack.Item item) throws ClassNotFoundException {
Comparable<?> aliasReg = (Comparable<?>) item.getUserValue();
if (aliasReg instanceof String) {
return (String) aliasReg;
}
XField field = item.getXField();
if (fiel... | java | @Nullable
private String isFieldCollection(OpcodeStack.Item item) throws ClassNotFoundException {
Comparable<?> aliasReg = (Comparable<?>) item.getUserValue();
if (aliasReg instanceof String) {
return (String) aliasReg;
}
XField field = item.getXField();
if (fiel... | [
"@",
"Nullable",
"private",
"String",
"isFieldCollection",
"(",
"OpcodeStack",
".",
"Item",
"item",
")",
"throws",
"ClassNotFoundException",
"{",
"Comparable",
"<",
"?",
">",
"aliasReg",
"=",
"(",
"Comparable",
"<",
"?",
">",
")",
"item",
".",
"getUserValue",
... | determines if the stack item refers to a collection that is stored in a field
@param item
the stack item to check
@return the field name of the collection, or null
@throws ClassNotFoundException
if the items class cannot be found | [
"determines",
"if",
"the",
"stack",
"item",
"refers",
"to",
"a",
"collection",
"that",
"is",
"stored",
"in",
"a",
"field"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UseAddAll.java#L276-L294 | train |
mebigfatguy/fb-contrib | src/samples/java/ex/OCP_Sample.java | OCP_Sample.getDisplay | public String getDisplay(HashSet<String> s, String a, String b) {
if (s.contains(a)) {
s.add(b);
} else {
s.add(a + b);
}
StringBuilder sb = new StringBuilder();
Iterator<String> it = s.iterator();
while (it.hasNext()) {
sb.append(it.n... | java | public String getDisplay(HashSet<String> s, String a, String b) {
if (s.contains(a)) {
s.add(b);
} else {
s.add(a + b);
}
StringBuilder sb = new StringBuilder();
Iterator<String> it = s.iterator();
while (it.hasNext()) {
sb.append(it.n... | [
"public",
"String",
"getDisplay",
"(",
"HashSet",
"<",
"String",
">",
"s",
",",
"String",
"a",
",",
"String",
"b",
")",
"{",
"if",
"(",
"s",
".",
"contains",
"(",
"a",
")",
")",
"{",
"s",
".",
"add",
"(",
"b",
")",
";",
"}",
"else",
"{",
"s",... | tag OCP, hashset could be Set instead | [
"tag",
"OCP",
"hashset",
"could",
"be",
"Set",
"instead"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/samples/java/ex/OCP_Sample.java#L44-L57 | train |
mebigfatguy/fb-contrib | src/samples/java/ex/OCP_Sample.java | OCP_Sample.max | public String max(List<String> s) {
String max = "";
for (String p : s) {
if (p.length() > max.length()) {
max = p;
}
}
return max;
} | java | public String max(List<String> s) {
String max = "";
for (String p : s) {
if (p.length() > max.length()) {
max = p;
}
}
return max;
} | [
"public",
"String",
"max",
"(",
"List",
"<",
"String",
">",
"s",
")",
"{",
"String",
"max",
"=",
"\"\"",
";",
"for",
"(",
"String",
"p",
":",
"s",
")",
"{",
"if",
"(",
"p",
".",
"length",
"(",
")",
">",
"max",
".",
"length",
"(",
")",
")",
... | List should be declared as Collection where possible | [
"List",
"should",
"be",
"declared",
"as",
"Collection",
"where",
"possible"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/samples/java/ex/OCP_Sample.java#L60-L69 | train |
mebigfatguy/fb-contrib | src/samples/java/ex/OCP_Sample.java | OCP_Sample.parse | public void parse(DefaultHandler dh, File f) throws SAXException, ParserConfigurationException, IOException {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
xr.setContentHandler(dh);
xr.parse(new InputS... | java | public void parse(DefaultHandler dh, File f) throws SAXException, ParserConfigurationException, IOException {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
xr.setContentHandler(dh);
xr.parse(new InputS... | [
"public",
"void",
"parse",
"(",
"DefaultHandler",
"dh",
",",
"File",
"f",
")",
"throws",
"SAXException",
",",
"ParserConfigurationException",
",",
"IOException",
"{",
"SAXParserFactory",
"spf",
"=",
"SAXParserFactory",
".",
"newInstance",
"(",
")",
";",
"SAXParser... | tag OCP dh could be a ContentHandler instead | [
"tag",
"OCP",
"dh",
"could",
"be",
"a",
"ContentHandler",
"instead"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/samples/java/ex/OCP_Sample.java#L72-L79 | train |
mebigfatguy/fb-contrib | src/samples/java/ex/OCP_Sample.java | OCP_Sample.httpComponentWithTryFalseNegative | public static void httpComponentWithTryFalseNegative(HttpPut request, String auth) {
auth = auth + "password";
try {
// this will probably be tagged with
// CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET, if compiled under JDK 7
// or later
request.addHeader("Au... | java | public static void httpComponentWithTryFalseNegative(HttpPut request, String auth) {
auth = auth + "password";
try {
// this will probably be tagged with
// CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET, if compiled under JDK 7
// or later
request.addHeader("Au... | [
"public",
"static",
"void",
"httpComponentWithTryFalseNegative",
"(",
"HttpPut",
"request",
",",
"String",
"auth",
")",
"{",
"auth",
"=",
"auth",
"+",
"\"password\"",
";",
"try",
"{",
"// this will probably be tagged with",
"// CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET, if c... | should tag OCP request -> HTTPMessage, but doesnt | [
"should",
"tag",
"OCP",
"request",
"-",
">",
"HTTPMessage",
"but",
"doesnt"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/samples/java/ex/OCP_Sample.java#L183-L193 | train |
mebigfatguy/fb-contrib | src/samples/java/ex/OCP_Sample.java | fpGenericConstrainedInterface.compare | @Override
public int compare(GregorianCalendar c1, GregorianCalendar c2) {
if (c2.getGregorianChange() == null) {
return (int) (c1.getTime().getTime() - c2.getTime().getTime());
} else {
return 0;
}
} | java | @Override
public int compare(GregorianCalendar c1, GregorianCalendar c2) {
if (c2.getGregorianChange() == null) {
return (int) (c1.getTime().getTime() - c2.getTime().getTime());
} else {
return 0;
}
} | [
"@",
"Override",
"public",
"int",
"compare",
"(",
"GregorianCalendar",
"c1",
",",
"GregorianCalendar",
"c2",
")",
"{",
"if",
"(",
"c2",
".",
"getGregorianChange",
"(",
")",
"==",
"null",
")",
"{",
"return",
"(",
"int",
")",
"(",
"c1",
".",
"getTime",
"... | this method is really suspect, but will ignore this case | [
"this",
"method",
"is",
"really",
"suspect",
"but",
"will",
"ignore",
"this",
"case"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/samples/java/ex/OCP_Sample.java#L237-L244 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java | UseCharacterParameterizedMethod.visitClassContext | @Override
public void visitClassContext(final ClassContext context) {
try {
stack = new OpcodeStack();
super.visitClassContext(context);
} finally {
stack = null;
}
} | java | @Override
public void visitClassContext(final ClassContext context) {
try {
stack = new OpcodeStack();
super.visitClassContext(context);
} finally {
stack = null;
}
} | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"final",
"ClassContext",
"context",
")",
"{",
"try",
"{",
"stack",
"=",
"new",
"OpcodeStack",
"(",
")",
";",
"super",
".",
"visitClassContext",
"(",
"context",
")",
";",
"}",
"finally",
"{",
"sta... | overrides the visitor to create and clear the opcode stack
@param context
the context object for the currently parsed class | [
"overrides",
"the",
"visitor",
"to",
"create",
"and",
"clear",
"the",
"opcode",
"stack"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java#L117-L125 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java | UseCharacterParameterizedMethod.prescreen | private boolean prescreen(Method obj) {
BitSet bytecodeSet = getClassContext().getBytecodeSet(obj);
return (bytecodeSet != null) && ((bytecodeSet.get(Const.LDC) || (bytecodeSet.get(Const.LDC_W))));
} | java | private boolean prescreen(Method obj) {
BitSet bytecodeSet = getClassContext().getBytecodeSet(obj);
return (bytecodeSet != null) && ((bytecodeSet.get(Const.LDC) || (bytecodeSet.get(Const.LDC_W))));
} | [
"private",
"boolean",
"prescreen",
"(",
"Method",
"obj",
")",
"{",
"BitSet",
"bytecodeSet",
"=",
"getClassContext",
"(",
")",
".",
"getBytecodeSet",
"(",
"obj",
")",
";",
"return",
"(",
"bytecodeSet",
"!=",
"null",
")",
"&&",
"(",
"(",
"bytecodeSet",
".",
... | looks for methods that contain a LDC opcode
@param obj
the context object of the current method
@return if the class uses LDC instructions | [
"looks",
"for",
"methods",
"that",
"contain",
"a",
"LDC",
"opcode"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java#L135-L138 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java | UseCharacterParameterizedMethod.visitCode | @Override
public void visitCode(Code obj) {
if (prescreen(getMethod())) {
stack.resetForMethodEntry(this);
super.visitCode(obj);
}
} | java | @Override
public void visitCode(Code obj) {
if (prescreen(getMethod())) {
stack.resetForMethodEntry(this);
super.visitCode(obj);
}
} | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"if",
"(",
"prescreen",
"(",
"getMethod",
"(",
")",
")",
")",
"{",
"stack",
".",
"resetForMethodEntry",
"(",
"this",
")",
";",
"super",
".",
"visitCode",
"(",
"obj",
")",
"... | prescreens the method, and reset the stack
@param obj
the context object for the currently parsed method | [
"prescreens",
"the",
"method",
"and",
"reset",
"the",
"stack"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java#L146-L152 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java | UseCharacterParameterizedMethod.sawOpcode | @Override
public void sawOpcode(int seen) {
try {
stack.precomputation(this);
if ((seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKEINTERFACE)) {
FQMethod key = new FQMethod(getClassConstantOperand(), getNameConstantOperand(), getSigConstantOperand());
... | java | @Override
public void sawOpcode(int seen) {
try {
stack.precomputation(this);
if ((seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKEINTERFACE)) {
FQMethod key = new FQMethod(getClassConstantOperand(), getNameConstantOperand(), getSigConstantOperand());
... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"try",
"{",
"stack",
".",
"precomputation",
"(",
"this",
")",
";",
"if",
"(",
"(",
"seen",
"==",
"Const",
".",
"INVOKEVIRTUAL",
")",
"||",
"(",
"seen",
"==",
"Const",
".",
... | implements the visitor to look for method calls that pass a constant string as a parameter when the string is only one character long, and there is an
alternate method passing a character. | [
"implements",
"the",
"visitor",
"to",
"look",
"for",
"method",
"calls",
"that",
"pass",
"a",
"constant",
"string",
"as",
"a",
"parameter",
"when",
"the",
"string",
"is",
"only",
"one",
"character",
"long",
"and",
"there",
"is",
"an",
"alternate",
"method",
... | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java#L158-L197 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java | UseCharacterParameterizedMethod.callHasInline | @Nullable
private UCPMUserValue callHasInline(int seen) {
if (seen != Const.INVOKEVIRTUAL) {
return null;
}
String sig = getSigConstantOperand();
String returnSig = SignatureUtils.getReturnSignature(sig);
if (Values.SIG_JAVA_UTIL_STRINGBUILDER.equals(returnSig) |... | java | @Nullable
private UCPMUserValue callHasInline(int seen) {
if (seen != Const.INVOKEVIRTUAL) {
return null;
}
String sig = getSigConstantOperand();
String returnSig = SignatureUtils.getReturnSignature(sig);
if (Values.SIG_JAVA_UTIL_STRINGBUILDER.equals(returnSig) |... | [
"@",
"Nullable",
"private",
"UCPMUserValue",
"callHasInline",
"(",
"int",
"seen",
")",
"{",
"if",
"(",
"seen",
"!=",
"Const",
".",
"INVOKEVIRTUAL",
")",
"{",
"return",
"null",
";",
"}",
"String",
"sig",
"=",
"getSigConstantOperand",
"(",
")",
";",
"String"... | checks to see if the current opcode is an INVOKEVIRTUAL call that has a INLINE userValue on the caller and a return value. If so, return it.
@param seen
the currently parsed opcode
@return whether the caller has an INLINE tag on it | [
"checks",
"to",
"see",
"if",
"the",
"current",
"opcode",
"is",
"an",
"INVOKEVIRTUAL",
"call",
"that",
"has",
"a",
"INLINE",
"userValue",
"on",
"the",
"caller",
"and",
"a",
"return",
"value",
".",
"If",
"so",
"return",
"it",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java#L251-L268 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java | SloppyClassReflection.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
try {
refClasses = new HashSet<>();
refClasses.add(classContext.getJavaClass().getClassName());
state = State.COLLECT;
super.visitClassContext(classContext);
state = State.SEEN_NO... | java | @Override
public void visitClassContext(ClassContext classContext) {
try {
refClasses = new HashSet<>();
refClasses.add(classContext.getJavaClass().getClassName());
state = State.COLLECT;
super.visitClassContext(classContext);
state = State.SEEN_NO... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"try",
"{",
"refClasses",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"refClasses",
".",
"add",
"(",
"classContext",
".",
"getJavaClass",
"(",
")",
".",
... | overrides the visitor to collect all class references
@param classContext
the class context of the currently visited class | [
"overrides",
"the",
"visitor",
"to",
"collect",
"all",
"class",
"references"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java#L73-L85 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java | SloppyClassReflection.sawOpcode | @Override
public void sawOpcode(int seen) {
switch (state) {
case COLLECT:
if ((seen == Const.INVOKESTATIC) || (seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKEINTERFACE) || (seen == Const.INVOKESPECIAL)) {
refClasses.add(getClassConstantOperand());
... | java | @Override
public void sawOpcode(int seen) {
switch (state) {
case COLLECT:
if ((seen == Const.INVOKESTATIC) || (seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKEINTERFACE) || (seen == Const.INVOKESPECIAL)) {
refClasses.add(getClassConstantOperand());
... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"switch",
"(",
"state",
")",
"{",
"case",
"COLLECT",
":",
"if",
"(",
"(",
"seen",
"==",
"Const",
".",
"INVOKESTATIC",
")",
"||",
"(",
"seen",
"==",
"Const",
".",
"INVOKEVIR... | overrides the visitor to find class loading that is non obfuscation proof
@param seen
the opcode that is being visited | [
"overrides",
"the",
"visitor",
"to",
"find",
"class",
"loading",
"that",
"is",
"non",
"obfuscation",
"proof"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java#L138-L173 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java | SloppyClassReflection.addType | private void addType(Type t) {
String signature = t.getSignature();
if (signature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX)) {
refClasses.add(SignatureUtils.trimSignature(signature));
}
} | java | private void addType(Type t) {
String signature = t.getSignature();
if (signature.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX)) {
refClasses.add(SignatureUtils.trimSignature(signature));
}
} | [
"private",
"void",
"addType",
"(",
"Type",
"t",
")",
"{",
"String",
"signature",
"=",
"t",
".",
"getSignature",
"(",
")",
";",
"if",
"(",
"signature",
".",
"startsWith",
"(",
"Values",
".",
"SIG_QUALIFIED_CLASS_PREFIX",
")",
")",
"{",
"refClasses",
".",
... | add the type string represented by the type to the refClasses set if it is a reference
@param t
the type to add | [
"add",
"the",
"type",
"string",
"represented",
"by",
"the",
"type",
"to",
"the",
"refClasses",
"set",
"if",
"it",
"is",
"a",
"reference"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java#L181-L186 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleUnsuspectedSerialization.java | PossibleUnsuspectedSerialization.sawOpcode | @Override
public void sawOpcode(int seen) {
try {
stack.precomputation(this);
if (seen == Const.INVOKEVIRTUAL) {
String clsName = getClassConstantOperand();
if ("java/io/ObjectOutputStream".equals(clsName)) {
String name = getNameC... | java | @Override
public void sawOpcode(int seen) {
try {
stack.precomputation(this);
if (seen == Const.INVOKEVIRTUAL) {
String clsName = getClassConstantOperand();
if ("java/io/ObjectOutputStream".equals(clsName)) {
String name = getNameC... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"try",
"{",
"stack",
".",
"precomputation",
"(",
"this",
")",
";",
"if",
"(",
"seen",
"==",
"Const",
".",
"INVOKEVIRTUAL",
")",
"{",
"String",
"clsName",
"=",
"getClassConstant... | implements the visitor to look for serialization of an object that is an non-static inner class.
@param seen
the context object of the currently parsed instruction | [
"implements",
"the",
"visitor",
"to",
"look",
"for",
"serialization",
"of",
"an",
"object",
"that",
"is",
"an",
"non",
"-",
"static",
"inner",
"class",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleUnsuspectedSerialization.java#L89-L114 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/UseSplit.java | UseSplit.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
try {
JavaClass cls = classContext.getJavaClass();
if (cls.getMajor() >= Const.MAJOR_1_4) {
stack = new OpcodeStack();
regValueType = new HashMap<Integer, State>();
su... | java | @Override
public void visitClassContext(ClassContext classContext) {
try {
JavaClass cls = classContext.getJavaClass();
if (cls.getMajor() >= Const.MAJOR_1_4) {
stack = new OpcodeStack();
regValueType = new HashMap<Integer, State>();
su... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"try",
"{",
"JavaClass",
"cls",
"=",
"classContext",
".",
"getJavaClass",
"(",
")",
";",
"if",
"(",
"cls",
".",
"getMajor",
"(",
")",
">=",
"Const",
".",... | implements the visitor to make sure the class is at least java 1.4 and to reset the opcode stack | [
"implements",
"the",
"visitor",
"to",
"make",
"sure",
"the",
"class",
"is",
"at",
"least",
"java",
"1",
".",
"4",
"and",
"to",
"reset",
"the",
"opcode",
"stack"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/UseSplit.java#L71-L84 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java | AbstractOverriddenMethod.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
try {
clsContext = classContext;
JavaClass cls = classContext.getJavaClass();
if (cls.isInterface())
return;
superClasses = cls.getSuperClasses();
cls.accept(this)... | java | @Override
public void visitClassContext(ClassContext classContext) {
try {
clsContext = classContext;
JavaClass cls = classContext.getJavaClass();
if (cls.isInterface())
return;
superClasses = cls.getSuperClasses();
cls.accept(this)... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"try",
"{",
"clsContext",
"=",
"classContext",
";",
"JavaClass",
"cls",
"=",
"classContext",
".",
"getJavaClass",
"(",
")",
";",
"if",
"(",
"cls",
".",
"is... | implements the detector to collect the super classes
@param classContext
the context object for the currently parsed class | [
"implements",
"the",
"detector",
"to",
"collect",
"the",
"super",
"classes"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java#L57-L72 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java | AbstractOverriddenMethod.visitMethod | @Override
public void visitMethod(Method obj) {
if (!obj.isAbstract())
return;
String methodName = obj.getName();
String methodSig = obj.getSignature();
outer: for (JavaClass cls : superClasses) {
Method[] methods = cls.getMethods();
for (Method m... | java | @Override
public void visitMethod(Method obj) {
if (!obj.isAbstract())
return;
String methodName = obj.getName();
String methodSig = obj.getSignature();
outer: for (JavaClass cls : superClasses) {
Method[] methods = cls.getMethods();
for (Method m... | [
"@",
"Override",
"public",
"void",
"visitMethod",
"(",
"Method",
"obj",
")",
"{",
"if",
"(",
"!",
"obj",
".",
"isAbstract",
"(",
")",
")",
"return",
";",
"String",
"methodName",
"=",
"obj",
".",
"getName",
"(",
")",
";",
"String",
"methodSig",
"=",
"... | overrides the visitor to find abstract methods that override concrete ones
@param obj
the context object of the currently parsed method | [
"overrides",
"the",
"visitor",
"to",
"find",
"abstract",
"methods",
"that",
"override",
"concrete",
"ones"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java#L80-L104 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java | ConfusingAutoboxedOverloading.visitClassContext | @Override
public void visitClassContext(ClassContext classContext) {
JavaClass cls = classContext.getJavaClass();
if (cls.isClass() && (cls.getMajor() >= JDK15_MAJOR)) {
Map<String, Set<String>> methodInfo = new HashMap<>();
populateMethodInfo(cls, methodInfo);
... | java | @Override
public void visitClassContext(ClassContext classContext) {
JavaClass cls = classContext.getJavaClass();
if (cls.isClass() && (cls.getMajor() >= JDK15_MAJOR)) {
Map<String, Set<String>> methodInfo = new HashMap<>();
populateMethodInfo(cls, methodInfo);
... | [
"@",
"Override",
"public",
"void",
"visitClassContext",
"(",
"ClassContext",
"classContext",
")",
"{",
"JavaClass",
"cls",
"=",
"classContext",
".",
"getJavaClass",
"(",
")",
";",
"if",
"(",
"cls",
".",
"isClass",
"(",
")",
"&&",
"(",
"cls",
".",
"getMajor... | overrides the visitor to look for confusing signatures
@param classContext
the context object that holds the JavaClass currently being parsed | [
"overrides",
"the",
"visitor",
"to",
"look",
"for",
"confusing",
"signatures"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java#L81-L106 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java | ConfusingAutoboxedOverloading.confusingSignatures | private static boolean confusingSignatures(String sig1, String sig2) {
if (sig1.equals(sig2)) {
return false;
}
List<String> type1 = SignatureUtils.getParameterSignatures(sig1);
List<String> type2 = SignatureUtils.getParameterSignatures(sig2);
if (type1.size() != ty... | java | private static boolean confusingSignatures(String sig1, String sig2) {
if (sig1.equals(sig2)) {
return false;
}
List<String> type1 = SignatureUtils.getParameterSignatures(sig1);
List<String> type2 = SignatureUtils.getParameterSignatures(sig2);
if (type1.size() != ty... | [
"private",
"static",
"boolean",
"confusingSignatures",
"(",
"String",
"sig1",
",",
"String",
"sig2",
")",
"{",
"if",
"(",
"sig1",
".",
"equals",
"(",
"sig2",
")",
")",
"{",
"return",
"false",
";",
"}",
"List",
"<",
"String",
">",
"type1",
"=",
"Signatu... | returns if one signature is a Character and the other is a primitive
@param sig1
the first method signature
@param sig2
the second method signature
@return if one signature is a Character and the other a primitive | [
"returns",
"if",
"one",
"signature",
"is",
"a",
"Character",
"and",
"the",
"other",
"is",
"a",
"primitive"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java#L118-L152 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java | ConfusingAutoboxedOverloading.populateMethodInfo | private void populateMethodInfo(JavaClass cls, Map<String, Set<String>> methodInfo) {
try {
if (Values.DOTTED_JAVA_LANG_OBJECT.equals(cls.getClassName())) {
return;
}
Method[] methods = cls.getMethods();
for (Method m : methods) {
... | java | private void populateMethodInfo(JavaClass cls, Map<String, Set<String>> methodInfo) {
try {
if (Values.DOTTED_JAVA_LANG_OBJECT.equals(cls.getClassName())) {
return;
}
Method[] methods = cls.getMethods();
for (Method m : methods) {
... | [
"private",
"void",
"populateMethodInfo",
"(",
"JavaClass",
"cls",
",",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"methodInfo",
")",
"{",
"try",
"{",
"if",
"(",
"Values",
".",
"DOTTED_JAVA_LANG_OBJECT",
".",
"equals",
"(",
"cls",
".",
"ge... | fills out a set of method details for possibly confusing method signatures
@param cls
the current class being parsed
@param methodInfo
a collection to hold possibly confusing methods | [
"fills",
"out",
"a",
"set",
"of",
"method",
"details",
"for",
"possibly",
"confusing",
"method",
"signatures"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java#L162-L187 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java | ConfusingAutoboxedOverloading.isPossiblyConfusingSignature | private static boolean isPossiblyConfusingSignature(String sig) {
List<String> types = SignatureUtils.getParameterSignatures(sig);
for (String typeSig : types) {
if (primitiveSigs.contains(typeSig) || SignatureUtils.classToSignature(Values.SLASHED_JAVA_LANG_CHARACTER).equals(typeSig)) {
... | java | private static boolean isPossiblyConfusingSignature(String sig) {
List<String> types = SignatureUtils.getParameterSignatures(sig);
for (String typeSig : types) {
if (primitiveSigs.contains(typeSig) || SignatureUtils.classToSignature(Values.SLASHED_JAVA_LANG_CHARACTER).equals(typeSig)) {
... | [
"private",
"static",
"boolean",
"isPossiblyConfusingSignature",
"(",
"String",
"sig",
")",
"{",
"List",
"<",
"String",
">",
"types",
"=",
"SignatureUtils",
".",
"getParameterSignatures",
"(",
"sig",
")",
";",
"for",
"(",
"String",
"typeSig",
":",
"types",
")",... | returns whether a method signature has either a Character or primitive
@param sig
the method signature
@return whether a method signature has either a Character or primitive | [
"returns",
"whether",
"a",
"method",
"signature",
"has",
"either",
"a",
"Character",
"or",
"primitive"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java#L197-L205 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java | InappropriateToStringUse.visitCode | @Override
public void visitCode(Code obj) {
stack.resetForMethodEntry(this);
toStringRegisters.clear();
super.visitCode(obj);
} | java | @Override
public void visitCode(Code obj) {
stack.resetForMethodEntry(this);
toStringRegisters.clear();
super.visitCode(obj);
} | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"stack",
".",
"resetForMethodEntry",
"(",
"this",
")",
";",
"toStringRegisters",
".",
"clear",
"(",
")",
";",
"super",
".",
"visitCode",
"(",
"obj",
")",
";",
"}"
] | overrides the visitor to resets the stack for this method.
@param obj
the context object for the currently parsed code block | [
"overrides",
"the",
"visitor",
"to",
"resets",
"the",
"stack",
"for",
"this",
"method",
"."
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java#L117-L122 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java | InappropriateToStringUse.sawOpcode | @Override
public void sawOpcode(int seen) {
String methodPackage = null;
try {
stack.precomputation(this);
if (seen == Const.INVOKEVIRTUAL) {
methodPackage = processInvokeVirtual();
} else if (OpcodeUtils.isAStore(seen)) {
if (sta... | java | @Override
public void sawOpcode(int seen) {
String methodPackage = null;
try {
stack.precomputation(this);
if (seen == Const.INVOKEVIRTUAL) {
methodPackage = processInvokeVirtual();
} else if (OpcodeUtils.isAStore(seen)) {
if (sta... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"String",
"methodPackage",
"=",
"null",
";",
"try",
"{",
"stack",
".",
"precomputation",
"(",
"this",
")",
";",
"if",
"(",
"seen",
"==",
"Const",
".",
"INVOKEVIRTUAL",
")",
"... | overrides the visitor to look for suspicious operations on toString | [
"overrides",
"the",
"visitor",
"to",
"look",
"for",
"suspicious",
"operations",
"on",
"toString"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java#L127-L166 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java | ExceptionSoftening.visitCode | @Override
public void visitCode(Code obj) {
try {
Method method = getMethod();
if (method.isSynthetic()) {
return;
}
isBooleanMethod = Type.BOOLEAN.equals(method.getReturnType());
if (isBooleanMethod || prescreen(method)) {
... | java | @Override
public void visitCode(Code obj) {
try {
Method method = getMethod();
if (method.isSynthetic()) {
return;
}
isBooleanMethod = Type.BOOLEAN.equals(method.getReturnType());
if (isBooleanMethod || prescreen(method)) {
... | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"try",
"{",
"Method",
"method",
"=",
"getMethod",
"(",
")",
";",
"if",
"(",
"method",
".",
"isSynthetic",
"(",
")",
")",
"{",
"return",
";",
"}",
"isBooleanMethod",
"=",
"T... | overrides the visitor to look for methods that catch checked exceptions and
rethrow runtime exceptions
@param obj the context object of the currently parsed code block | [
"overrides",
"the",
"visitor",
"to",
"look",
"for",
"methods",
"that",
"catch",
"checked",
"exceptions",
"and",
"rethrow",
"runtime",
"exceptions"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java#L120-L153 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java | ExceptionSoftening.sawOpcode | @Override
public void sawOpcode(int seen) {
try {
stack.precomputation(this);
int pc = getPC();
CodeException ex = catchHandlerPCs.get(Integer.valueOf(pc));
if (ex != null) {
int endPC;
if ((seen == Const.GOTO) || (seen == Cons... | java | @Override
public void sawOpcode(int seen) {
try {
stack.precomputation(this);
int pc = getPC();
CodeException ex = catchHandlerPCs.get(Integer.valueOf(pc));
if (ex != null) {
int endPC;
if ((seen == Const.GOTO) || (seen == Cons... | [
"@",
"Override",
"public",
"void",
"sawOpcode",
"(",
"int",
"seen",
")",
"{",
"try",
"{",
"stack",
".",
"precomputation",
"(",
"this",
")",
";",
"int",
"pc",
"=",
"getPC",
"(",
")",
";",
"CodeException",
"ex",
"=",
"catchHandlerPCs",
".",
"get",
"(",
... | overrides the visitor to find catch blocks that throw runtime exceptions
@param seen the opcode of the currently parsed instruction | [
"overrides",
"the",
"visitor",
"to",
"find",
"catch",
"blocks",
"that",
"throw",
"runtime",
"exceptions"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java#L160-L193 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java | ExceptionSoftening.removeFinishedCatchBlocks | private static void removeFinishedCatchBlocks(Iterable<CatchInfo> infos, int pc) {
Iterator<CatchInfo> it = infos.iterator();
while (it.hasNext()) {
if (it.next().getFinish() < pc) {
it.remove();
}
}
} | java | private static void removeFinishedCatchBlocks(Iterable<CatchInfo> infos, int pc) {
Iterator<CatchInfo> it = infos.iterator();
while (it.hasNext()) {
if (it.next().getFinish() < pc) {
it.remove();
}
}
} | [
"private",
"static",
"void",
"removeFinishedCatchBlocks",
"(",
"Iterable",
"<",
"CatchInfo",
">",
"infos",
",",
"int",
"pc",
")",
"{",
"Iterator",
"<",
"CatchInfo",
">",
"it",
"=",
"infos",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNex... | remove catchinfo blocks from the map where the handler end is before the
current pc
@param infos the exception handlers installed
@param pc the current pc | [
"remove",
"catchinfo",
"blocks",
"from",
"the",
"map",
"where",
"the",
"handler",
"end",
"is",
"before",
"the",
"current",
"pc"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java#L315-L322 | train |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java | ExceptionSoftening.updateEndPCsOnCatchRegScope | private void updateEndPCsOnCatchRegScope(List<CatchInfo> infos, int pc, int seen) {
if (lvt != null) {
for (CatchInfo ci : infos) {
if ((ci.getStart() == pc) && OpcodeUtils.isAStore(seen)) {
int exReg = RegisterUtils.getAStoreReg(this, seen);
L... | java | private void updateEndPCsOnCatchRegScope(List<CatchInfo> infos, int pc, int seen) {
if (lvt != null) {
for (CatchInfo ci : infos) {
if ((ci.getStart() == pc) && OpcodeUtils.isAStore(seen)) {
int exReg = RegisterUtils.getAStoreReg(this, seen);
L... | [
"private",
"void",
"updateEndPCsOnCatchRegScope",
"(",
"List",
"<",
"CatchInfo",
">",
"infos",
",",
"int",
"pc",
",",
"int",
"seen",
")",
"{",
"if",
"(",
"lvt",
"!=",
"null",
")",
"{",
"for",
"(",
"CatchInfo",
"ci",
":",
"infos",
")",
"{",
"if",
"(",... | reduces the end pc based on the optional LocalVariableTable's exception
register scope
@param infos the list of active catch blocks
@param pc the current pc
@param seen the currently parsed opcode | [
"reduces",
"the",
"end",
"pc",
"based",
"on",
"the",
"optional",
"LocalVariableTable",
"s",
"exception",
"register",
"scope"
] | 3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8 | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java#L332-L345 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.