Scan swift source code failed on kvo

If your question is about SonarLint in the IntelliJ Platform, VS Code, Visual Studio, or Eclipse, please post it in that sub-category.

Otherwise, please provide:

  • Operating system: Mac
  • IDE name and flavor/env: Xcode

And a thorough description of the problem / question:

the key problem is "" in swift kvo, cause error in sonar scan

kvo code sample:

observation = observe(
            \.objectToObserve.myDate,
            options: [.old, .new]
        ) { object, change in
            print("myDate changed from: xxx")
        }

logs:

[ERROR] Failed to analyze file xxx.swift
java.lang.RuntimeException: Exception during execution of merge for nonterminal KEY_PATH_EXPRESSION
at org.sonar.sslr.gll.grammar2.ProductionAction$Merge.run(Unknown Source)
at org.sonar.sslr.gll.grammar2.ProductionAction.setResultOrMerge(Unknown Source)
at org.sonar.sslr.gll.grammar2.ProductionAction$Call.execute(Unknown Source)
at org.sonar.sslr.gll.grammar2.ProductionAction$Call.execute(Unknown Source)
at org.sonar.sslr.gll.internal.sppf.PackedNode.performGrammarActions(Unknown Source)
at org.sonar.sslr.gll.internal.sppf.PackedNode.performGrammarActions(Unknown Source)
at org.sonar.sslr.gll.internal.sppf.PackedNode.performGrammarActions(Unknown Source)
at org.sonar.sslr.gll.internal.sppf.PackedNode.performGrammarActions(Unknown Source)
at org.sonar.sslr.gll.internal.sppf.NonterminalNode.performGrammarActions(Unknown Source)
at org.sonar.sslr.gll.internal.sppf.PackedNode.performGrammarActionsForRightNodes(Unknown Source)

Caused by: com.sonarsource.swift.A: Unhandled ambiguity in PATTERN grammar rule at line 154 column 1
at com.sonarsource.swift.grammar.TreeFactory.disambiguateKeyPathExpression(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
… 76 common frames omitted

Hey there.

There’s no SonarLint for XCode – in what context are you receiving this error?

Hi Colin, sorry, i don’t know what is the static analyse tool exactly, i just guest it’s sonar lint, i just use sonar scanner to scan my iOS project source code, and facing this error on kvo of swift, what is the analyse tool sonar scanner used now?