Package org.sonar.squidbridge.api

Examples of org.sonar.squidbridge.api.SourceFile


  @Test
  public void test() {
    LineLengthCheck check = new LineLengthCheck();
    check.maximumLineLength = 30;

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/lineLength.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(2).withMessage("The line contains 44 characters which is greater than 30 authorized.")
        .noMore();
  }
View Full Code Here


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

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/redeclaredVariable.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(3).withMessage("Rename variable \"a\" as this name is already used.")
        .next().atLine(7).withMessage("Rename variable \"a\" as this name is already used.")
        .next().atLine(12).withMessage("Rename variable \"i\" as this name is already used.")
        .next().atLine(19).withMessage("Rename variable \"b\" as this name is already used.")
        .next().atLine(23).withMessage("Rename variable \"a\" as this name is already used.")
View Full Code Here

  @Test
  public void test() {
    FunctionComplexityCheck check = new FunctionComplexityCheck();
    check.setMaximumFunctionComplexityThreshold(2);

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/functionComplexity.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(1).withMessage("Function has a complexity of 5 which is greater than 2 authorized.")
        .next().atLine(14)
        .noMore();
  }
View Full Code Here

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

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/nonEmptyCaseWithoutBreak.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(9).withMessage("Last statement in this switch-clause should be an unconditional break.")
        .next().atLine(16)
        .noMore();
  }
View Full Code Here

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

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/functionDeclarationsWithinBlocks.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(3).withMessage("Do not use function declarations within blocks.")
        .noMore();
  }
View Full Code Here

public class CommentedCodeCheckTest {

  @Test
  public void test() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/commentedCode.js"), new CommentedCodeCheck());
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(7).withMessage("Sections of code should not be \"commented out\".")
        .next().atLine(14)
        .noMore();
  }
View Full Code Here

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

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/constructorFunctionsForSideEffects.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(3).withMessage("Replace by a standard call to the function.")
        .noMore();
  }
View Full Code Here

public class SwitchWithNotEnoughCaseCheckTest {

  private SwitchWithNotEnoughCaseCheck check = new SwitchWithNotEnoughCaseCheck();
  @Test
  public void test() {
    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/switchWithNotEnoughCase.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
      .next().atLine(1)
      .next().atLine(9)
      .noMore();

  }
View Full Code Here

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

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/tooManyBreakOrContinueInLoop.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(1).withMessage("Reduce the total number of \"break\" and \"continue\" statements in this loop to use one at most.")
        .next().atLine(16)
        .next().atLine(36)
        .next().atLine(48)
        .next().atLine(65)
View Full Code Here

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

    SourceFile file = JavaScriptAstScanner.scanSingleFile(new File("src/test/resources/checks/arrayAndObjectConstructors.js"), check);
    CheckMessagesVerifier.verify(file.getCheckMessages())
        .next().atLine(2).withMessage("Use a literal instead of the Array constructor.")
        .next().atLine(3).withMessage("Use a literal instead of the Array constructor.")
        .next().atLine(5).withMessage("Use a literal instead of the Object constructor.")
        .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.