Report cases when class member can be private
This commit is contained in:
committed by
Dmitry Jemerov
parent
c83b764c73
commit
753b714544
+110
@@ -0,0 +1,110 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>13</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Property 'a' can be private</description>
|
||||
</problem>
|
||||
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>19</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Function 'f1' can be private</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>20</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Function 'f2' can be private</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>65</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Property 'y' can be private</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>68</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Function 'f2' can be private</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>78</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Property 'a' can be private</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>79</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Property 'b' can be private</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>80</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Property 'c' can be private</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>109</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Property 'a' can be private</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>110</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Property 'b' can be private</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>114</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Function 'f1' can be private</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>115</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can have 'private' visibility</problem_class>
|
||||
<description>Function 'f2' can be private</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+1
@@ -0,0 +1 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.MemberVisibilityCanPrivateInspection
|
||||
@@ -0,0 +1,129 @@
|
||||
val a = "a"
|
||||
|
||||
fun f1() {}
|
||||
|
||||
fun f2() {
|
||||
println(a)
|
||||
f1()
|
||||
A().b
|
||||
}
|
||||
|
||||
class A {
|
||||
val unused = ""
|
||||
val a = ""
|
||||
internal val b = ""
|
||||
protected val c = ""
|
||||
private val d = ""
|
||||
|
||||
fun unused() {}
|
||||
fun f1() {}
|
||||
internal fun f2() {}
|
||||
protected fun f3() {}
|
||||
private fun f4() {}
|
||||
|
||||
fun bar() {
|
||||
println(a)
|
||||
println(b)
|
||||
println(c)
|
||||
println(d)
|
||||
f1()
|
||||
f2()
|
||||
f3()
|
||||
f4()
|
||||
}
|
||||
}
|
||||
|
||||
interface I {
|
||||
val x: String
|
||||
fun foo()
|
||||
}
|
||||
|
||||
class B : I {
|
||||
override val x: String
|
||||
get() = ""
|
||||
|
||||
override fun foo() {
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
println(x)
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
interface I2 {
|
||||
val x: String
|
||||
fun foo()
|
||||
fun bar() {
|
||||
println(x)
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
open class C {
|
||||
open val x = ""
|
||||
protected val y = ""
|
||||
|
||||
open fun f1() {}
|
||||
protected fun f2() {}
|
||||
|
||||
fun bar() {
|
||||
println(x)
|
||||
println(y)
|
||||
f1()
|
||||
f2()
|
||||
}
|
||||
}
|
||||
|
||||
class D(val a: String = "",
|
||||
var b: String = "",
|
||||
internal val c: String = "",
|
||||
protected val d: String = "",
|
||||
private val e: String = "") {
|
||||
fun foo() {
|
||||
println(a)
|
||||
println(b)
|
||||
println(c)
|
||||
println(d)
|
||||
println(e)
|
||||
}
|
||||
}
|
||||
|
||||
open class E(override val x: String = "",
|
||||
open val a: String = "") : I {
|
||||
override fun foo() {}
|
||||
fun foo() {
|
||||
println(x)
|
||||
println(a)
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
var v1 = ""
|
||||
val v2 = ""
|
||||
println(v1)
|
||||
println(v2)
|
||||
}
|
||||
}
|
||||
|
||||
val x = object {
|
||||
val a: String = "",
|
||||
internal val b: String = "",
|
||||
protected val c: String = "",
|
||||
private val d: String = ""
|
||||
|
||||
fun f1() {}
|
||||
internal fun f2() {}
|
||||
protected fun f3() {}
|
||||
private fun f4() {}
|
||||
|
||||
fun foo() {
|
||||
println(a)
|
||||
println(b)
|
||||
println(c)
|
||||
println(d)
|
||||
f1()
|
||||
f2()
|
||||
f3()
|
||||
f4()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user