Package ch.hortis.sonar.model

Examples of ch.hortis.sonar.model.RuleFailure


  private List<RuleFailure> getFailuresForGivenLine( File toHighlight, List<RuleFailure> failuresForFile, int lineNumber ) {
    List<RuleFailure> failuresForGivenLine = new ArrayList<RuleFailure>();
    if ( failuresForFile != null ) {
      for (Iterator<RuleFailure> i = failuresForFile.iterator(); i.hasNext();) {
        RuleFailure failure = i.next();
        Parameter lineParam = failure.getParameter( "line" );
        if ( lineParam.getValue().intValue() == lineNumber ) {
          failuresForGivenLine.add( failure );
          i.remove();
        }
      }
View Full Code Here


  }

  private void purgeRuleFailures( Snapshot snapshot ) {
    List<RuleFailure> ruleFailures = snapshot.getRuleFailures();
    for ( Iterator<RuleFailure> iter = ruleFailures.iterator(); iter.hasNext(); ) {
      RuleFailure failure = iter.next();
      deleteParameters(failure.getParameters());
      if ( LOG.isDebugEnabled() ) LOG.debug( "Removing RuleFailure " + failure.getId() );
      getEntityManager().remove( failure );
      iter.remove();
    }
  }
View Full Code Here

  }

  private void purgeRuleFailures(Snapshot snapshot) {
    List<RuleFailure> ruleFailures = snapshot.getRuleFailures();
    for (Iterator<RuleFailure> iter = ruleFailures.iterator(); iter.hasNext();) {
      RuleFailure failure = iter.next();
      deleteParameters(failure.getParameters());
      getEntityManager().remove(failure);
      iter.remove();
    }
  }
View Full Code Here

  private List<RuleFailure> getFailuresForGivenLine(File toHighlight, List<RuleFailure> failuresForFile, int lineNumber) {
    List<RuleFailure> failuresForGivenLine = new ArrayList<RuleFailure>();
    if (failuresForFile != null) {
      for (Iterator<RuleFailure> i = failuresForFile.iterator(); i.hasNext();) {
        RuleFailure failure = i.next();
        Parameter lineParam = failure.getParameter("line");
        if (lineParam.getValue().intValue() == lineNumber) {
          failuresForGivenLine.add(failure);
          i.remove();
        }
      }
View Full Code Here

  }

  private void purgeRuleFailures(Snapshot snapshot) {
    List<RuleFailure> ruleFailures = snapshot.getRuleFailures();
    for (Iterator<RuleFailure> iter = ruleFailures.iterator(); iter.hasNext();) {
      RuleFailure failure = iter.next();
      deleteParameters(failure.getParameters());
      getEntityManager().remove(failure);
      iter.remove();
    }
  }
View Full Code Here

        if (filename == null || "".equals(filename)) {
          filename = StringUtils.substringAfterLast(name, "\\");
        }
        List<Element> violations = parser.getChildElements(element, "violation");
        for (Element violation : violations) {
          RuleFailure failure = new RuleFailure();
          Rule rule = getRuleService().getRuleByPluginKey(violation.getAttribute("rule"));
          if (rule == null) {
            continue;
          }
          failure.setRule(rule);

          File file = getFilesRepository().getFile(violation.getAttribute("package"), filename);
          failure.setFile(file);
          String line = violation.getAttribute("line");
          if (line != null && !"".equals(line)) {
            failure.addParameter("line", Double.valueOf(line));
          }
          failure.setMessage(violation.getFirstChild().getNodeValue());
          int priority = Integer.parseInt(violation.getAttribute("priority"));
          if (priority <= 2) {
            failure.setLevel(RuleFailureLevel.ERROR);
          } else if (priority == 3 || priority == 4) {
            failure.setLevel(RuleFailureLevel.WARNING);
          } else {
            failure.setLevel(RuleFailureLevel.INFO);
          }
          failures.add(failure);
        }
      }
    }
View Full Code Here

        Element element = (Element) files.item(i);
        String checkstyleName = element.getAttribute("name");

        List<Element> errors = reportParser.getChildElements(element, "error");
        for (Element error : errors) {
          RuleFailure failure = new RuleFailure();
          String source = error.getAttribute("source");
          if (rulesService.getRuleByPluginKey(source) == null) {
            continue;
          }
          failure.setRule(rulesService.getRuleByPluginKey(source));
          failure.setFile(getFile(checkstyleName));
          failure.setMessage(error.getAttribute("message"));
          String line = error.getAttribute("line");
          if (line != null && !"".equals(line)) {
            failure.addParameter("line", Double.valueOf(line));
          }
          String column = error.getAttribute("column");
          if (column != null && !"".equals(column)) {
            failure.addParameter("column", Double.valueOf(column));
          }
          String severity = error.getAttribute("severity");
          if ("error".equals(severity)) {
            failure.setLevel(RuleFailureLevel.ERROR);
          } else if ("warning".equals(severity)) {
            failure.setLevel(RuleFailureLevel.WARNING);
          } else {
            failure.setLevel(RuleFailureLevel.INFO);
          }

          failures.add(failure);
        }
      }
View Full Code Here

        Element element = (Element) files.item( i );
        String checkstyleName = element.getAttribute( "name" );

        List<Element> errors = reportParser.getChildElements( element, "error" );
        for (Element error : errors) {
          RuleFailure failure = new RuleFailure();
          String source = error.getAttribute( "source" );
          if ( rulesService.getRuleByPluginKey( source ) == null ) {
            continue;
          }
          failure.setRule( rulesService.getRuleByPluginKey( source ) );
          failure.setFile( getFile( checkstyleName ) );
          failure.setMessage( error.getAttribute( "message" ) );
          String line = error.getAttribute( "line" );
          if ( line != null && !"".equals( line ) ) {
            failure.addParameter( "line", Double.valueOf( line ) );
          }
          String column = error.getAttribute( "column" );
          if ( column != null && !"".equals( column ) ) {
            failure.addParameter( "column", Double.valueOf( column ) );
          }
          String severity = error.getAttribute( "severity" );
          if ( "error".equals( severity ) ) {
            failure.setLevel( RuleFailureLevel.ERROR );
          } else if ( "warning".equals( severity ) ) {
            failure.setLevel( RuleFailureLevel.WARNING );
          } else {
            failure.setLevel( RuleFailureLevel.INFO );
          }

          failures.add( failure );
        }
      }
View Full Code Here

        if ( filename == null || "".equals( filename ) ) {
          filename = StringUtils.substringAfterLast( name, "\\" );
        }
        List<Element> violations = parser.getChildElements( element, "violation" );
        for (Element violation : violations) {
          RuleFailure failure = new RuleFailure();
          Rule rule = getRuleService().getRuleByPluginKey( violation.getAttribute( "rule" ) );
          if ( rule == null ) {
            continue;
          }
          failure.setRule( rule );

          File file = getFilesRepository().getFile( violation.getAttribute( "package" ), filename );
          failure.setFile( file );
          String line = violation.getAttribute( "line" );
          if ( line != null && !"".equals( line ) ) {
            failure.addParameter( "line", Double.valueOf( line ) );
          }
          failure.setMessage( violation.getFirstChild().getNodeValue() );
          int priority = Integer.parseInt( violation.getAttribute( "priority" ) );
          if ( priority <= 2 ) {
            failure.setLevel( RuleFailureLevel.ERROR );
          } else if ( priority == 3 || priority == 4 ) {
            failure.setLevel( RuleFailureLevel.WARNING );
          } else {
            failure.setLevel( RuleFailureLevel.INFO );
          }
          failures.add( failure );
        }
      }
    }
View Full Code Here

TOP

Related Classes of ch.hortis.sonar.model.RuleFailure

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.