Java Code Examples for org.sonar.squidbridge.checks.CheckMessagesVerifier#verify()

The following examples show how to use org.sonar.squidbridge.checks.CheckMessagesVerifier#verify() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CssCheckVerifier.java    From sonar-css-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * See {@link CssCheckVerifier#issuesOnCssFile(CssCheck, File)}
 *
 * @param charset Charset of the file to test.
 */
public static CheckMessagesVerifier issuesOnCssFile(CssCheck check, File file, Charset charset) {
  if (check instanceof CharsetAwareVisitor) {
    ((CharsetAwareVisitor) check).setCharset(charset);
  }
  return CheckMessagesVerifier.verify(TreeCheckTest.getIssues(file.getAbsolutePath(), check, CssParser.createParser(charset)));
}
 
Example 2
Source File: CssCheckVerifier.java    From sonar-css-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * See {@link CssCheckVerifier#issuesOnEmbeddedCssFile(CssCheck, File)}
 *
 * @param charset Charset of the file to test.
 */
public static CheckMessagesVerifier issuesOnEmbeddedCssFile(CssCheck check, File file, Charset charset) {
  if (check instanceof CharsetAwareVisitor) {
    ((CharsetAwareVisitor) check).setCharset(charset);
  }
  return CheckMessagesVerifier.verify(TreeCheckTest.getIssues(file.getAbsolutePath(), check, EmbeddedCssParser.createParser(charset)));
}
 
Example 3
Source File: CssCheckVerifier.java    From sonar-css-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * See {@link CssCheckVerifier#issuesOnLessFile(CssCheck, File)}
 *
 * @param charset Charset of the file to test.
 */
public static CheckMessagesVerifier issuesOnLessFile(CssCheck check, File file, Charset charset) {
  if (check instanceof CharsetAwareVisitor) {
    ((CharsetAwareVisitor) check).setCharset(charset);
  }
  return CheckMessagesVerifier.verify(TreeCheckTest.getIssues(file.getAbsolutePath(), check, LessParser.createParser(charset)));
}
 
Example 4
Source File: CssCheckVerifier.java    From sonar-css-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * See {@link CssCheckVerifier#issuesOnScssFile(CssCheck, File)}
 *
 * @param charset Charset of the file to test.
 */
public static CheckMessagesVerifier issuesOnScssFile(CssCheck check, File file, Charset charset) {
  if (check instanceof CharsetAwareVisitor) {
    ((CharsetAwareVisitor) check).setCharset(charset);
  }
  return CheckMessagesVerifier.verify(TreeCheckTest.getIssues(file.getAbsolutePath(), check, ScssParser.createParser(charset)));
}
 
Example 5
Source File: ClassLengthCheckTest.java    From enforce-sonarqube-plugin with MIT License 5 votes vote down vote up
@Test
public void testErrorClassLength() throws Exception {
	classLengthCheck = new ClassLengthCheck();
    sourceFile = scanFile(new File("src/test/resources/checks/ClassLengthError.cls"), classLengthCheck);
    CheckMessagesVerifier chkMsgVerify = CheckMessagesVerifier.verify(sourceFile.getCheckMessages());
    //System.out.println("chkMsgVerify: "+ sourceFile.getCheckMessages());
    // For Class
    chkMsgVerify = chkMsgVerify.next();
    chkMsgVerify.atLine(2).withMessage("The maximum number of statements in class is: "+classLengthCheck.DEFAULT_CLASS_LENGTH+".");
    
}
 
Example 6
Source File: VariableCountCheckTest.java    From enforce-sonarqube-plugin with MIT License 5 votes vote down vote up
@Test
public void testErrorVariableCount() throws Exception {
	variableCountCheck = new VariableCountCheck();
    sourceFile = scanFile(new File("src/test/resources/checks/VariableCountCheckErrorClass.cls"), variableCountCheck);
    CheckMessagesVerifier chkMsgVerify = CheckMessagesVerifier.verify(sourceFile.getCheckMessages());
    
    chkMsgVerify = chkMsgVerify.next();
    chkMsgVerify.atLine(1).withMessage("Classes that have too many fields/variables can become unwieldy and could be redesigned to have fewer,possibly through grouping related fields/variables in new objects. The maximum number of fields/variables in class is: "+variableCountCheck.DEFAULT_VARIABLE_COUNT+".");
}
 
Example 7
Source File: MethodLengthCheckTest.java    From enforce-sonarqube-plugin with MIT License 5 votes vote down vote up
@Test
public void testErrorMethodLength() throws Exception {
	methodLengthCheck = new MethodLengthCheck();
    sourceFile = scanFile(new File("src/test/resources/checks/ClassLengthError.cls"), methodLengthCheck);
    CheckMessagesVerifier chkMsgVerify = CheckMessagesVerifier.verify(sourceFile.getCheckMessages());
    
    chkMsgVerify.next().withMessage("The maximum number of statements in method is: "+ methodLengthCheck.DEFAULT_METHOD_LENGTH+".");
    
}
 
Example 8
Source File: ParameterCountCheckTest.java    From enforce-sonarqube-plugin with MIT License 5 votes vote down vote up
@Test
public void testErrorParameterCount() throws Exception {
	parameterCountCheck = new ParameterCountCheck();
    sourceFile = scanFile(new File("src/test/resources/checks/clazzError.cls"), parameterCountCheck);
    CheckMessagesVerifier chkMsgVerify = CheckMessagesVerifier.verify(sourceFile.getCheckMessages());
    
    // For Method
    chkMsgVerify = chkMsgVerify.next();
    chkMsgVerify.atLine(26).withMessage("The maximum number of parameters in method/constructor is: "+parameterCountCheck.DEFAULT_PARAM_COUNT+".");
    
    // For Constructor
    chkMsgVerify = chkMsgVerify.next();
    chkMsgVerify.atLine(30).withMessage("The maximum number of parameters in method/constructor is: "+parameterCountCheck.DEFAULT_PARAM_COUNT+".");
}
 
Example 9
Source File: GherkinCheckVerifier.java    From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * See {@link GherkinCheckVerifier#issues(GherkinCheck, File)}
 *
 * @param charset Charset of the file to test.
 */
public static CheckMessagesVerifier issues(GherkinCheck check, File file, Charset charset) {
  if (check instanceof CharsetAwareVisitor) {
    ((CharsetAwareVisitor) check).setCharset(charset);
  }
  return CheckMessagesVerifier.verify(TreeCheckTest.getIssues(file.getAbsolutePath(), check, charset, GherkinDialectProvider.DEFAULT_LANGUAGE));
}
 
Example 10
Source File: GherkinCheckVerifier.java    From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * See {@link GherkinCheckVerifier#issues(GherkinCheck, File)}
 *
 * @param language Language of the file to test.
 */
public static CheckMessagesVerifier issues(GherkinCheck check, File file, String language) {
  if (check instanceof CharsetAwareVisitor) {
    ((CharsetAwareVisitor) check).setCharset(Charsets.UTF_8);
  }
  return CheckMessagesVerifier.verify(TreeCheckTest.getIssues(file.getAbsolutePath(), check, Charsets.UTF_8, language));
}