private void CheckTestMethodHasCodeAndCreateWarningIfNot(ICSharpFunctionDeclaration declaration)
        {
            var statements = declaration.Body.Statements;

            if (!statements.Any())
            {
                IHighlighting highlighting = new TestMethodMissingCodeWarning(declaration, "Test method is empty");
                AddHighlighting(declaration.GetNameDocumentRange(), highlighting);
            }
        }
        /// <summary>
        /// Processes the function declaration.
        /// </summary>
        /// <param name="declaration">The declaration.</param>
        private void ProcessFunctionDeclaration(ICSharpFunctionDeclaration declaration)
        {
            // Nothing to calculate
            if (declaration.Body == null)
            {
                return;
            }

            int cyclomatic = CalcCyclomaticComplexity(declaration);

            // Placing highlighting
            if (cyclomatic > myThreshold)
            {
                string message = string.Format("Member has cyclomatic complexity of {0} ({1}%)", cyclomatic, (int)(cyclomatic * 100.0 / myThreshold));
                var    warning = new ComplexityWarning(message);
                myHighlightings.Add(new HighlightingInfo(declaration.GetNameDocumentRange(), warning));
            }
        }
    /// <summary>
    /// Processes the function declaration.
    /// </summary>
    /// <param name="declaration">The declaration.</param>
    private void ProcessFunctionDeclaration(ICSharpFunctionDeclaration declaration)
    {
      // Nothing to calculate
      if(declaration.Body == null)
        return;

      int cyclomatic = CalcCyclomaticComplexity(declaration);

      // Placing highlighting
      if(cyclomatic > myThreshold)
      {
        string message = string.Format("Member has cyclomatic complexity of {0} ({1}%)", cyclomatic, (int)(cyclomatic * 100.0 / myThreshold));
        var warning = new ComplexityWarning(message);
        myHighlightings.Add(new HighlightingInfo(declaration.GetNameDocumentRange(), warning));
      }
    }
예제 #4
0
 public DocumentRange CalculateRange()
 {
     return(myDeclaration.GetNameDocumentRange());
 }