3

我使用声纳检查 jquery 代码,但它总是抛出异常:

C:\Documents and Settings\user\.jenkins\workspace\ksp2\ant\sonar_web.xml:31: com.sonar.sslr.impl.LexerException: Unable to lex url: file:/C:/Documents%20and%20Settings/user/.jenkins/workspace/ksp2/WebContent/js/post/viewEditRevisions.js
Caused by: com.sonar.sslr.impl.LexerException: Unable to lex source code at line : 197 and column : 42 in file : file:/C:/Documents%20and%20Settings/user/.jenkins/workspace/ksp2/WebContent/js/post/viewEditRevisions.js
Caused by: java.lang.IllegalStateException: None of the channel has been able to handle character '"' (decimal value 34) at line 197, column 42
    at org.sonar.channel.ChannelDispatcher.consume(ChannelDispatcher.java:87)
    at com.sonar.sslr.impl.Lexer.lex(Lexer.java:126)

我不知道为什么。我的 jquery 文件太长,它在这一行抛出异常:

    var postTemplate = '<h3><div class="title">'+data.postResult.title+'</div></h3><p>'+data.postResult.contentPreview+'</p>'+postTags;

我很困惑,我将编码设置为 UTF-8,但它仍然抛出异常。

4

1 回答 1

3

您可以尝试这种方式: sonar_web.xml 添加以下代码<property key="sonar.sourceEncoding" value="utf-8" />

参考:https ://stackoverflow.com/a/15537832/2193246

于 2013-03-21T01:26:40.583 回答