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

import io.gitlab.arturbosch.detekt.test.lint
import org.assertj.core.api.Assertions.*
import org.jetbrains.spek.api.dsl.describe
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.subject.SubjectSpek

class RedundantModifierRuleSpec : SubjectSpek<RedundantModifierRule>({
	subject { RedundantModifierRule() }
	describe("check all cases") {
		it("check overridden function of abstract") {
			val code = """
				abstract class A {
					abstract protected fun A()
				}

				class Test : A() {
					override public fun A() {}
				}
			"""
			assertThat(subject.lint(code)).hasSize(0)
		}

		it("check overridden function of interface") {
			val code = """
				interface A {
					fun A()
				}

				class Test : A {
					override public fun A() {}
				}
			"""
			assertThat(subject.lint(code)).hasSize(0)
		}

		it("check public function") {
			val code = """
				class Test{
					public fun A() {}
				}
			"""
			assertThat(subject.lint(code)).hasSize(1)
		}

		it("check function w/o modifier") {
			val code = """
				class Test{
					fun A() {}
				}
			"""
			assertThat(subject.lint(code)).hasSize(0)
		}
	}
})


<commit_msg>add more tests<commit_after>package io.gitlab.arturbosch.detekt.rules.style

import io.gitlab.arturbosch.detekt.test.lint
import org.assertj.core.api.Assertions.*
import org.jetbrains.spek.api.dsl.describe
import org.jetbrains.spek.api.dsl.it
import org.jetbrains.spek.subject.SubjectSpek

class RedundantModifierRuleSpec : SubjectSpek<RedundantModifierRule>({
	subject { RedundantModifierRule() }
	describe("check all cases") {
		it("check overridden function of abstract") {
			val code = """
				abstract class A {
					abstract protected fun A()
				}

				class Test : A() {
					override public fun A() {}
				}
			"""
			assertThat(subject.lint(code)).hasSize(0)
		}

		it("check overridden function of interface") {
			val code = """
				interface A {
					fun A()
				}

				class Test : A {
					override public fun A() {}
				}
			"""
			assertThat(subject.lint(code)).hasSize(0)
		}

		it("check public function") {
			val code = """
				class Test{
					public fun A() {}
				}
			"""
			assertThat(subject.lint(code)).hasSize(1)
		}

		it("check function w/o modifier") {
			val code = """
				class Test{
					fun A() {}
				}
			"""
			assertThat(subject.lint(code)).hasSize(0)
		}

		it("check public class") {
			val code = """
				public class Test(){
					fun test(){}
				}
			"""
			assertThat(subject.lint(code)).hasSize(1)
		}

		it("check interface w/ public modifier") {
			val code = """
				public interface Test{
					public fun test()
				}
			"""
			assertThat(subject.lint(code)).hasSize(2)
		}
	}
})



{'fraction_non_alphanumeric': 0.14489051094890512, 'fraction_numerical': 0.0036496350364963502, 'mean_word_length': 2.8660084626234132, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1378998', 'n_tokens_mistral': 1171, 'n_tokens_neox': 928, 'n_words': 193}