Examples of SourceFunction


Examples of org.sonar.squid.api.SourceFunction

    subscribeTo(CxxGrammarImpl.functionDefinition);
  }

  @Override
  public void leaveNode(AstNode node) {
    SourceFunction sourceFunction = (SourceFunction) getContext().peekSourceCode();
    int complexity = ChecksHelper.getRecursiveMeasureInt(sourceFunction, CxxMetric.COMPLEXITY);
    if (complexity > max) {
      getContext().createLineViolation(this,
          "The Cyclomatic Complexity of this function is {0,number,integer} which is greater than {1,number,integer} authorized.",
          node,
View Full Code Here

Examples of org.sonar.squid.api.SourceFunction

        StringBuilder sb = new StringBuilder();
        for (Token token : astNode.getFirstDescendant(CxxGrammarImpl.declaratorId).getTokens()) {
          sb.append(token.getValue());
        }
        String functionName = sb.toString();
        SourceFunction function = new SourceFunction(functionName + ":" + astNode.getToken().getLine());
        function.setStartAtLine(astNode.getTokenLine());
        return function;
      }
    }, CxxGrammarImpl.functionDefinition));

    builder.withSquidAstVisitor(CounterVisitor.<Grammar> builder()
View Full Code Here

Examples of org.sonar.squidbridge.api.SourceFunction

      EcmaScriptGrammar.FUNCTION_EXPRESSION);
  }

  @Override
  public void leaveNode(AstNode node) {
    SourceFunction function = (SourceFunction) getContext().peekSourceCode();
    if (function.getInt(EcmaScriptMetric.COMPLEXITY) > maximumFunctionComplexityThreshold) {
      getContext().createLineViolation(this,
        "Function has a complexity of {0,number,integer} which is greater than {1,number,integer} authorized.", node,
        function.getInt(EcmaScriptMetric.COMPLEXITY), maximumFunctionComplexityThreshold);
    }
  }
View Full Code Here

Examples of org.sonar.squidbridge.api.SourceFunction

    builder.withSquidAstVisitor(new SourceCodeBuilderVisitor<LexerlessGrammar>(new SourceCodeBuilderCallback() {
      public SourceCode createSourceCode(SourceCode parentSourceCode, AstNode astNode) {
        AstNode identifier = astNode.getFirstChild(EcmaScriptTokenType.IDENTIFIER, EcmaScriptGrammar.PROPERTY_NAME, EcmaScriptGrammar.BINDING_IDENTIFIER);
        final String functionName = identifier == null ? "anonymous" : identifier.getTokenValue();
        final String fileKey = parentSourceCode.isType(SourceFile.class) ? parentSourceCode.getKey() : parentSourceCode.getParent(SourceFile.class).getKey();
        SourceFunction function = new SourceFunction(fileKey + ":" + functionName + ":" + astNode.getToken().getLine() + ":" + astNode.getToken().getColumn());
        function.setStartAtLine(astNode.getTokenLine());
        return function;
      }
    }, FUNCTION_NODES));

    /* Metrics */
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.