代码之家  ›  专栏  ›  技术社区  ›  bright

声纳检查jquery代码错误

  •  3
  • bright  · 技术社区  · 13 年前

    我使用sonar来检查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,但它仍然抛出异常。

    1 回复  |  直到 13 年前
        1
  •  3
  •   Community Mohan Dere    9 年前

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

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