<commit_before>package edu.umd.cs.findbugs;
import java.util.*;
import java.io.PrintStream;
import org.apache.bcel.classfile.*;
import java.util.zip.*;
import java.io.*;
import edu.umd.cs.pugh.visitclass.Constants2;

public class FindHEmismatch extends BytecodeScanningDetector implements   Constants2 {
   String prevClassName = " none ";
   boolean firstTime = true;
   boolean hasFields = false;
   boolean hasHashCode = false;
   boolean hasEqualsObject = false;
   boolean hasCompareToObject = false;
   boolean hasEqualsSelf = false;
   boolean hasCompareToSelf = false;
   boolean isInterface = false;
   boolean extendsObject = false;
   private BugReporter bugReporter;

   public FindHEmismatch(BugReporter bugReporter) {
	this.bugReporter = bugReporter;
   }

   public void report() {
	if (!hasEqualsObject &&  hasEqualsSelf) {
		if (extendsObject) 
		  bugReporter.reportBug(new BugInstance("EQ_SELF_USE_OBJECT", NORMAL_PRIORITY).addClass(prevClassName));
		else
		  bugReporter.reportBug(new BugInstance("EQ_SELF_NO_OBJECT", NORMAL_PRIORITY).addClass(prevClassName));
		}


	if (!hasCompareToObject &&  hasCompareToSelf) {
		if (!extendsObject)
		  bugReporter.reportBug(new BugInstance("CO_SELF_NO_OBJECT", NORMAL_PRIORITY).addClass(prevClassName));
		}

	if (!hasFields) return;
	if (hasHashCode && !(hasEqualsObject ||  hasEqualsSelf))  {
		if (extendsObject) 
		  bugReporter.reportBug(new BugInstance("HE_HASHCODE_USE_OBJECT_EQUALS", NORMAL_PRIORITY).addClass(prevClassName));
		else
		  bugReporter.reportBug(new BugInstance("HE_HASHCODE_NO_EQUALS", NORMAL_PRIORITY). addClass(prevClassName));
		}
	if (!hasHashCode && (hasEqualsObject ||  hasEqualsSelf))  {
		if (extendsObject) 
		  bugReporter.reportBug(new BugInstance("HE_EQUALS_USE_HASHCODE", NORMAL_PRIORITY).addClass(prevClassName));
		else
		  bugReporter.reportBug(new BugInstance("HE_EQUALS_NO_HASHCODE", NORMAL_PRIORITY).addClass(prevClassName));
		}
	}
   public void visit(JavaClass obj) {
	if (!isInterface && !firstTime) report(System.out);
	extendsObject = betterSuperclassName.equals("java.lang.Object");
	firstTime = false;
	prevClassName = betterClassName;
	hasFields = false;
	hasHashCode = false;
	hasCompareToObject = false;
	hasCompareToSelf = false;
	hasEqualsObject = false;
	hasEqualsSelf = false;
	int accessFlags = obj.getAccessFlags();
	isInterface = ((accessFlags & ACC_INTERFACE) != 0);
	}

    public void visit(Field obj) {
	int accessFlags = obj.getAccessFlags();
	if ((accessFlags & ACC_STATIC) != 0) return;
	hasFields = true;
	}
    public void visit(Method obj) {
	int accessFlags = obj.getAccessFlags();
	if ((accessFlags & ACC_STATIC) != 0) return;
	String name = obj.getName();
	String sig = obj.getSignature();
	if ((accessFlags & ACC_ABSTRACT) != 0) {
		if (name.equals("equals")<commit_msg>Fixed so it doesn't call the wrong report() method.<commit_after>package edu.umd.cs.findbugs;
import java.util.*;
import java.io.PrintStream;
import org.apache.bcel.classfile.*;
import java.util.zip.*;
import java.io.*;
import edu.umd.cs.pugh.visitclass.Constants2;

public class FindHEmismatch extends BytecodeScanningDetector implements   Constants2 {
   String prevClassName = " none ";
   boolean firstTime = true;
   boolean hasFields = false;
   boolean hasHashCode = false;
   boolean hasEqualsObject = false;
   boolean hasCompareToObject = false;
   boolean hasEqualsSelf = false;
   boolean hasCompareToSelf = false;
   boolean isInterface = false;
   boolean extendsObject = false;
   private BugReporter bugReporter;

   public FindHEmismatch(BugReporter bugReporter) {
	this.bugReporter = bugReporter;
   }

   public void report() {
	if (!hasEqualsObject &&  hasEqualsSelf) {
		if (extendsObject) 
		  bugReporter.reportBug(new BugInstance("EQ_SELF_USE_OBJECT", NORMAL_PRIORITY).addClass(prevClassName));
		else
		  bugReporter.reportBug(new BugInstance("EQ_SELF_NO_OBJECT", NORMAL_PRIORITY).addClass(prevClassName));
		}


	if (!hasCompareToObject &&  hasCompareToSelf) {
		if (!extendsObject)
		  bugReporter.reportBug(new BugInstance("CO_SELF_NO_OBJECT", NORMAL_PRIORITY).addClass(prevClassName));
		}

	if (!hasFields) return;
	if (hasHashCode && !(hasEqualsObject ||  hasEqualsSelf))  {
		if (extendsObject) 
		  bugReporter.reportBug(new BugInstance("HE_HASHCODE_USE_OBJECT_EQUALS", NORMAL_PRIORITY).addClass(prevClassName));
		else
		  bugReporter.reportBug(new BugInstance("HE_HASHCODE_NO_EQUALS", NORMAL_PRIORITY). addClass(prevClassName));
		}
	if (!hasHashCode && (hasEqualsObject ||  hasEqualsSelf))  {
		if (extendsObject) 
		  bugReporter.reportBug(new BugInstance("HE_EQUALS_USE_HASHCODE", NORMAL_PRIORITY).addClass(prevClassName));
		else
		  bugReporter.reportBug(new BugInstance("HE_EQUALS_NO_HASHCODE", NORMAL_PRIORITY).addClass(prevClassName));
		}
	}
   public void visit(JavaClass obj) {
	if (!isInterface && !firstTime) report();
	extendsObject = betterSuperclassName.equals("java.lang.Object");
	firstTime = false;
	prevClassName = betterClassName;
	hasFields = false;
	hasHashCode = false;
	hasCompareToObject = false;
	hasCompareToSelf = false;
	hasEqualsObject = false;
	hasEqualsSelf = false;
	int accessFlags = obj.getAccessFlags();
	isInterface = ((accessFlags & ACC_INTERFACE) != 0);
	}

    public void visit(Field obj) {
	int accessFlags = obj.getAccessFlags();
	if ((accessFlags & ACC_STATIC) != 0) return;
	hasFields = true;
	}
    public void visit(Method obj) {
	int accessFlags = obj.getAccessFlags();
	if ((accessFlags & ACC_STATIC) != 0) return;
	String name = obj.getName();
	String sig = obj.getSignature();
	if ((accessFlags & ACC_ABSTRACT) != 0) {
		if (name.equals("equals")
{'fraction_non_alphanumeric': 0.11227385597729692, 'fraction_numerical': 0.002128414331323164, 'mean_word_length': 5.300558659217877, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6538043', 'n_tokens_mistral': 1910, 'n_tokens_neox': 1828, 'n_words': 373}