Skip to content

Commit cd64faf

Browse files
committed
Kotlin: ignore properties in java/internal-representation-exposure check
1 parent e9a304b commit cd64faf

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

java/ql/src/Violations of Best Practice/Implementation Hiding/ExposeRepresentation.ql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,12 @@ predicate exposesByStore(Callable c, Field f, Expr why, string whyText) {
120120

121121
from Callable c, Field f, Expr why, string whyText
122122
where
123-
exposesByReturn(c, f, why, whyText) or
124-
exposesByStore(c, f, why, whyText)
123+
(
124+
exposesByReturn(c, f, why, whyText) or
125+
exposesByStore(c, f, why, whyText)
126+
) and
127+
// Kotlin properties expose internal representation, but it's not accidental, so ignore them
128+
not exists(Property p | p.getBackingField() = f)
125129
select c,
126130
c.getName() + " exposes the internal representation stored in field " + f.getName() +
127131
". The value may be modified $@.", why.getLocation(), whyText
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
| ExposesRep.kt:2:5:2:49 | getStrings | getStrings exposes the internal representation stored in field strings. The value may be modified $@. | User.kt:3:12:3:18 | User.kt:3:12:3:18 | after this call to getStrings |

0 commit comments

Comments
 (0)