Package org.sonar.squidbridge.api

Examples of org.sonar.squidbridge.api.SourceFile


  @Test
  public void test() {
    SameNameForFunctionAndVariableCheck check = new SameNameForFunctionAndVariableCheck();

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/sameNameForFunctionAndVariable.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(2).withMessage("Refactor the code to avoid using \"fun1\" for both a variable and a function.")
        .next().atLine(7).withMessage("Refactor the code to avoid using \"fun2\" for both a variable and a function.")
        .next().atLine(14).withMessage("Refactor the code to avoid using \"foo1\" for both a variable and a function.")
        .next().atLine(19).withMessage("Refactor the code to avoid using \"foo2\" for both a variable and a function.")
        .next().atLine(26).withMessage("Refactor the code to avoid using \"fun4\" for both a variable and a function.")
View Full Code Here


public class ParsingErrorCheckTest {

  @Test
  public void test() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/parsingError.js"), new ParsingErrorCheck());
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(3).withMessageThat(containsString("Parse error"))
        .noMore();
  }
View Full Code Here

  private ExpressionComplexityCheck check = new ExpressionComplexityCheck();

  @Test
  public void test() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/expressionComplexity.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(1).withMessage("Reduce the number of conditional operators (4) used in the expression (maximum allowed " + check.max + ").")
      .next().atLine(3)
      .next().atLine(5)
      .next().atLine(8).withMessage("Reduce the number of conditional operators (6) used in the expression (maximum allowed " + check.max + ").")
      .next().atLine(28)
View Full Code Here

  @Test
  public void test() {
    VariableShadowingCheck check = new VariableShadowingCheck();

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/variableShadowing.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(2).withMessage("\"x\" hides variable declared in outer scope.")
        .next().atLine(8)
        .next().atLine(11)
        .next().atLine(14)
        .next().atLine(18)
View Full Code Here

  @Test
  public void test() {
    DuplicateFunctionArgumentCheck check = new DuplicateFunctionArgumentCheck();

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/duplicateFunctionArgument.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(3).withMessage("Rename or remove duplicate function argument 'a'.")
        .next().atLine(4).withMessage("Rename or remove duplicate function argument '\\u0061'.")
        .next().atLine(7).withMessage("Rename or remove duplicate function argument 'c'.")
        .next().atLine(18).withMessage("Rename or remove duplicate function argument 'a'.")
        .next().atLine(21).withMessage("Rename or remove duplicate function argument 'a'.")
View Full Code Here

  @Test
  public void test() {
    DuplicateFunctionArgumentCheck check = new DuplicateFunctionArgumentCheck();

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/duplicateFunctionArgument.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(3).withMessage("Rename or remove duplicate function argument 'a'.")
        .next().atLine(4).withMessage("Rename or remove duplicate function argument '\\u0061'.")
        .next().atLine(7).withMessage("Rename or remove duplicate function argument 'c'.")
        .next().atLine(18).withMessage("Rename or remove duplicate function argument 'a'.")
        .next().atLine(21).withMessage("Rename or remove duplicate function argument 'a'.")
View Full Code Here

  @Test
  public void test() {
    OneStatementPerLineCheck check = new OneStatementPerLineCheck();

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/oneStatementPerLine.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(2).withMessage("At most one statement is allowed per line, but 2 statements were found on this line.")
        .next().atLine(6)
        .noMore();
  }
View Full Code Here

  @Test
  public void test() {
    SwitchWithoutDefaultCheck check = new SwitchWithoutDefaultCheck();

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/switchWithoutDefault.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(8).withMessage("Avoid switch statement without a \"default\" clause.")
        .next().atLine(13).withMessage("\"default\" clause should be the last one.")
        .noMore();
  }
View Full Code Here

  @Test
  public void test() {
    DebuggerStatementCheck check = new DebuggerStatementCheck();

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/debuggerStatement.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(2).withMessage("Remove this debugger statement.")
        .noMore();
  }
View Full Code Here

  @Test
  public void test() {
    CollapsibleIfStatementsCheck check = new CollapsibleIfStatementsCheck();

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/collapsibleIfStatements.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(15).withMessage("Merge this if statement with the nested one.")

        .next().atLine(27).withMessage("Merge this if statement with the nested one.")

        .next().atLine(32).withMessage("Merge this if statement with the nested one.")
View Full Code Here

TOP

Related Classes of org.sonar.squidbridge.api.SourceFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.