rjmurillo/moq.analyzers

View on GitHub

Showing 27 of 513 total issues

File ConstructorArgumentsShouldMatchAnalyzer.cs has 321 lines of code (exceeds 250 allowed). Consider refactoring.
Open

using System.Diagnostics.CodeAnalysis;

namespace Moq.Analyzers;

/// <summary>
Severity: Minor
Found in src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs - About 3 hrs to fix

    Method AnyConstructorsFound has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
    Open

        [SuppressMessage("Design", "MA0051:Method is too long", Justification = "This should be refactored; suppressing for now to enable TreatWarningsAsErrors in CI.")]
        private static bool AnyConstructorsFound(
            IMethodSymbol[] constructors,
            ArgumentSyntax[] arguments,
            SyntaxNodeAnalysisContext context)
    Severity: Minor
    Found in src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method AnyConstructorsFound has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        [SuppressMessage("Design", "MA0051:Method is too long", Justification = "This should be refactored; suppressing for now to enable TreatWarningsAsErrors in CI.")]
        private static bool AnyConstructorsFound(
            IMethodSymbol[] constructors,
            ArgumentSyntax[] arguments,
            SyntaxNodeAnalysisContext context)
    Severity: Major
    Found in src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs - About 2 hrs to fix

      Method Analyze has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          [SuppressMessage("Design", "MA0051:Method is too long", Justification = "Should be fixed. Ignoring for now to avoid additional churn as part of larger refactor.")]
          private static void Analyze(SyntaxNodeAnalysisContext context)
          {
              InvocationExpressionSyntax setupInvocation = (InvocationExpressionSyntax)context.Node;
      
      
      Severity: Minor
      Found in src/Analyzers/SetupShouldBeUsedOnlyForOverridableMembersAnalyzer.cs - About 1 hr to fix

        Method GetAllMatchingSymbols has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static List<T> GetAllMatchingSymbols<T>(this SemanticModel semanticModel, ExpressionSyntax expression)
                where T : class
            {
                List<T> matchingSymbols = new();
        
        
        Severity: Minor
        Found in src/Common/SemanticModelExtensions.cs - About 1 hr to fix

          Method Analyze has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static void Analyze(SyntaxNodeAnalysisContext context)
              {
                  // Check Moq version and skip analysis if the version is 4.16.0 or later
                  AssemblyIdentity? moqAssembly = context.Compilation.ReferencedAssemblyNames.FirstOrDefault(a => a.Name.Equals("Moq", StringComparison.OrdinalIgnoreCase));
          
          
          Severity: Minor
          Found in src/Analyzers/SetupShouldNotIncludeAsyncResultAnalyzer.cs - About 1 hr to fix

            Method AnalyzeInvocation has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static void AnalyzeInvocation(
                    SyntaxNodeAnalysisContext context,
                    MoqKnownSymbols knownSymbols,
                    InvocationExpressionSyntax invocationExpressionSyntax)
                {
            Severity: Minor
            Found in src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs - About 1 hr to fix

              Method FixCallbackSignatureAsync has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static async Task<Document> FixCallbackSignatureAsync(SyntaxNode root, Document document, ParameterListSyntax? oldParameters, CancellationToken cancellationToken)
                  {
                      SemanticModel? semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
              
                      if (semanticModel is null)
              Severity: Minor
              Found in src/CodeFixes/CallbackSignatureShouldMatchMockedMethodCodeFix.cs - About 1 hr to fix

                Method RegisterCompilationStartAction has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private static void RegisterCompilationStartAction(CompilationStartAnalysisContext context)
                    {
                        MoqKnownSymbols knownSymbols = new(context.Compilation);
                
                        // Ensure Moq is referenced in the compilation
                Severity: Minor
                Found in src/Analyzers/SetExplicitMockBehaviorAnalyzer.cs - About 1 hr to fix

                  Method Analyze has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private static void Analyze(SyntaxNodeAnalysisContext context)
                      {
                          ObjectCreationExpressionSyntax objectCreation = (ObjectCreationExpressionSyntax)context.Node;
                  
                          // TODO Think how to make this piece more elegant while fast
                  Severity: Minor
                  Found in src/Analyzers/NoSealedClassMocksAnalyzer.cs - About 1 hr to fix

                    Method AnalyzeNewObject has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private static void AnalyzeNewObject(OperationAnalysisContext context, ImmutableArray<INamedTypeSymbol> mockTypes, INamedTypeSymbol mockBehaviorSymbol)
                        {
                            if (context.Operation is not IObjectCreationOperation creationOperation)
                            {
                                return;
                    Severity: Minor
                    Found in src/Analyzers/SetExplicitMockBehaviorAnalyzer.cs - About 1 hr to fix

                      Method CreateDiagnostic has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              this Location location,
                              DiagnosticDescriptor rule,
                              IEnumerable<Location>? additionalLocations,
                              ImmutableDictionary<string, string?>? properties,
                              params object?[]? messageArgs)
                      Severity: Minor
                      Found in src/Common/DiagnosticExtensions.cs - About 45 mins to fix

                        Method CreateDiagnostic has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                this SyntaxNode node,
                                DiagnosticDescriptor rule,
                                IEnumerable<Location>? additionalLocations,
                                ImmutableDictionary<string, string?>? properties,
                                params object?[]? messageArgs) => node
                        Severity: Minor
                        Found in src/Common/DiagnosticExtensions.cs - About 45 mins to fix

                          Method CreateDiagnostic has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  this IOperation operation,
                                  DiagnosticDescriptor rule,
                                  IEnumerable<Location>? additionalLocations,
                                  ImmutableDictionary<string, string?>? properties,
                                  params object?[]? messageArgs) => operation.Syntax.CreateDiagnostic(rule, additionalLocations, properties, messageArgs);
                          Severity: Minor
                          Found in src/Common/DiagnosticExtensions.cs - About 45 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                        if ((arguments.Length < fixedParametersCount
                                             || (!hasParams && arguments.Length > fixedParametersCount)
                                             || (!hasParams && arguments.Length != fixedParametersCount))
                                            && requiredParameters != arguments.Length)
                                        {
                            Severity: Major
                            Found in src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs - About 40 mins to fix

                              Method CreateDiagnostic has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                      this SyntaxNode node,
                                      DiagnosticDescriptor rule,
                                      ImmutableDictionary<string, string?>? properties,
                                      params object?[]? messageArgs) => node.CreateDiagnostic(rule, additionalLocations: null, properties, messageArgs);
                              Severity: Minor
                              Found in src/Common/DiagnosticExtensions.cs - About 35 mins to fix

                                Method CreateDiagnostic has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    this IOperation operation,
                                    DiagnosticDescriptor rule,
                                    ImmutableDictionary<string, string?>? properties,
                                    params object?[]? messageArgs) => operation.CreateDiagnostic(rule, additionalLocations: null, properties, messageArgs);
                                Severity: Minor
                                Found in src/Common/DiagnosticExtensions.cs - About 35 mins to fix

                                  Method CreateDiagnostic has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                          this Location location,
                                          DiagnosticDescriptor rule,
                                          ImmutableDictionary<string, string?>? properties,
                                          params object?[]? messageArgs) => location.CreateDiagnostic(rule, additionalLocations: null, properties, messageArgs);
                                  Severity: Minor
                                  Found in src/Common/DiagnosticExtensions.cs - About 35 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                        return;
                                    Severity: Major
                                    Found in src/Analyzers/SetupShouldBeUsedOnlyForOverridableMembersAnalyzer.cs - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                  return;
                                      Severity: Major
                                      Found in src/Analyzers/SetupShouldBeUsedOnlyForOverridableMembersAnalyzer.cs - About 30 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language