Skip to content

Commit deb24b9

Browse files
committed
Fixed a suggestion from Qodana
1 parent 9301d18 commit deb24b9

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/main/kotlin/org/domaframework/doma/intellij/action/sql/JumpToDeclarationFromSqlAction.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ class JumpToDeclarationFromSqlAction : AnAction() {
101101

102102
private fun countLeadingDoubleQuotes(s: String): Int {
103103
var count = 0
104-
for (i in 0..<s.length) {
105-
if (s[i] == '"') {
104+
for (char in s) {
105+
if (char == '"') {
106106
count++
107107
} else {
108108
break

src/main/kotlin/org/domaframework/doma/intellij/inspection/sql/inspector/SqlBindVariableValidInspector.kt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,12 @@ class SqlBindVariableValidInspector : LocalInspectionTool() {
9393
isOnTheFly: Boolean,
9494
): SqlVisitor = sqlVisitor(holder)
9595

96-
fun sqlVisitor(holder: ProblemsHolder): SqlVisitor {
96+
private fun sqlVisitor(holder: ProblemsHolder): SqlVisitor {
9797
return object : SqlVisitor() {
9898
override fun visitElement(o: PsiElement) {
99-
var file = o.containingFile ?: return
99+
val file = o.containingFile ?: return
100100
if (isJavaOrKotlinFileType(file) && o is PsiLiteralExpression) {
101-
val injectionFile = initInjectionElement(file, o.project, o)
102-
if (injectionFile == null) return
103-
101+
val injectionFile = initInjectionElement(file, o.project, o) ?: return
104102
injectionFile.accept(this)
105103
super.visitElement(o)
106104
}
@@ -132,14 +130,14 @@ class SqlBindVariableValidInspector : LocalInspectionTool() {
132130

133131
override fun visitElStaticFieldAccessExpr(o: SqlElStaticFieldAccessExpr) {
134132
super.visitElStaticFieldAccessExpr(o)
135-
var targetElement = o
133+
val targetElement = o
136134
checkStaticFieldAndMethodAccess(targetElement, holder)
137135
}
138136

139137
override fun visitElFieldAccessExpr(o: SqlElFieldAccessExpr) {
140138
super.visitElFieldAccessExpr(o)
141-
var file = o.containingFile ?: return
142-
var targetElement = o
139+
val file = o.containingFile ?: return
140+
val targetElement = o
143141

144142
// Get element inside block comment
145143
val blockElement =
@@ -162,8 +160,8 @@ class SqlBindVariableValidInspector : LocalInspectionTool() {
162160

163161
override fun visitElPrimaryExpr(o: SqlElPrimaryExpr) {
164162
super.visitElPrimaryExpr(o)
165-
var file = o.containingFile ?: return
166-
var targetElement = o
163+
val file = o.containingFile ?: return
164+
val targetElement = o
167165
val project = o.project
168166

169167
// Exclude fixed Literal

0 commit comments

Comments
 (0)