我使用声纳检查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,但它仍然会抛出异常。
答案 0 :(得分:3)
您可以尝试这种方式:sonar_web.xml添加以下代码<property key="sonar.sourceEncoding" value="utf-8" />