Package org.sonar.squidbridge.api

Examples of org.sonar.squidbridge.api.SourceFile


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

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/boundOrAssignedEvalOrArguments.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(1).withMessage("Remove the modification of \"eval\".")
        .next().atLine(2).withMessage("Remove the modification of \"arguments\".")
        .next().atLine(3).withMessage("Remove the modification of \"eval\".")
        .next().atLine(4).withMessage("Do not use \"arguments\" to declare a parameter - use another name.")
        .next().atLine(6).withMessage("Do not use \"eval\" to declare a variable - use another name.")
View Full Code Here


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

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/htmlComments.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(1).withMessage("Replace this HTML-style comment by a standard comment")
        .noMore();
  }
View Full Code Here

  private IfConditionalAlwaysTrueOrFalseCheck check = new IfConditionalAlwaysTrueOrFalseCheck();

  @Test
  public void test() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/ifConditionalAlwaysTrueOrFalse.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(9)
      .next().atLine(13)
      .noMore();
  }
View Full Code Here

  TrailingCommentCheck check = new TrailingCommentCheck();

  @Test
  public void defaults() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/trailingComment.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(2).withMessage("Move this trailing comment on the previous empty line.")
        .noMore();
  }
View Full Code Here

  @Test
  public void test() {
    check.setLegalCommentPattern("");

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/trailingComment.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(2).withMessage("Move this trailing comment on the previous empty line.")
        .next().atLine(8)
        .noMore();
  }
View Full Code Here

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

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/singleQuoteStringLiterals.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(2).withMessage("Replace double quotes by simple quote")
        .noMore();
  }
View Full Code Here

  private NestedControlFlowDepthCheck check = new NestedControlFlowDepthCheck();

  @Test
  public void testDefault() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/nestedControlFlowDepth.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(14).withMessage("Refactor this code to not nest more than 3 if/for/while/switch/try statements.")
      .next().atLine(17)
      .next().atLine(20)
      .next().atLine(23)
      .next().atLine(26)
View Full Code Here

  @Test
  public void testCustomDepth() {
    check.maximumNestingLevel = 4;

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/nestedControlFlowDepth.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(28).withMessage("Refactor this code to not nest more than 4 if/for/while/switch/try statements.")
      .noMore();
  }
View Full Code Here

  private CommaOperatorUseCheck check = new CommaOperatorUseCheck();

  @Test
  public void test() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/commaOperatorUse.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(1).withMessage("Remove use of this comma operator.")
      .next().atLine(3)
      .next().atLine(6)
      .next().atLine(8)
      .next().atLine(9)
View Full Code Here

  private FunctionCallArgumentsOnNewLineCheck check = new FunctionCallArgumentsOnNewLineCheck();

  @Test
  public void test() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/functionCallArgumentsOnNewLine.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(4).withMessage("Make those call arguments start on line 2")
      .next().atLine(9).withMessage("Make those call arguments start on line 8")
      .next().atLine(25).withMessage("Make those call arguments start on line 24")
      .noMore();
  }
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.