<commit_before>package io.gitlab.arturbosch.detekt.rules.bugs

import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.rules.Case
import io.gitlab.arturbosch.detekt.rules.CommonSpec
import io.gitlab.arturbosch.detekt.test.lint
import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.spek.api.dsl.given
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.subject.SubjectSpek
import org.jetbrains.spek.subject.itBehavesLike

/**
 * @author <NAME>
 */
class EqualsWithHashCodeExistSpec : SubjectSpek<EqualsWithHashCodeExist>({
	subject { EqualsWithHashCodeExist(Config.empty) }
	itBehavesLike(CommonSpec())

	given("some classes with equals() functions") {

		it("reports equals() without hashCode() functions") {
			val path = Case.NestedClasses.path()
			assertThat(subject.lint(path)).hasSize(2)
		}
	}
})<commit_msg>Added data class test for EqualsWithHashCodeExist<commit_after>package io.gitlab.arturbosch.detekt.rules.bugs

import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.rules.Case
import io.gitlab.arturbosch.detekt.rules.CommonSpec
import io.gitlab.arturbosch.detekt.test.lint
import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.spek.api.dsl.given
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.subject.SubjectSpek
import org.jetbrains.spek.subject.itBehavesLike

/**
 * @author <NAME>
 */
class EqualsWithHashCodeExistSpec : SubjectSpek<EqualsWithHashCodeExist>({
	subject { EqualsWithHashCodeExist(Config.empty) }
	itBehavesLike(CommonSpec())

	given("some classes with equals() functions") {

		it("reports equals() without hashCode() functions") {
			val path = Case.NestedClasses.path()
			assertThat(subject.lint(path)).hasSize(2)
		}
	}

	given("a data class") {

		it("does not report equals() or hashcode() violation") {
			val code = """
				data class EqualsData(val i: Int) {
					override fun equals(other: Any?): Boolean {
						return super.equals(other)
					}
				}"""
			assertThat(subject.lint(code)).hasSize(0)
		}
	}
})
{'fraction_non_alphanumeric': 0.12584704743465633, 'fraction_numerical': 0.001452081316553727, 'mean_word_length': 5.115384615384615, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4337939', 'n_tokens_mistral': 778, 'n_tokens_neox': 727, 'n_words': 114}