<commit_before>namespace FakeItEasy.Analyzer
{
    using System;
    using System.Collections.Immutable;
    using Microsoft.CodeAnalysis;
    using Microsoft.CodeAnalysis.CSharp;
    using Microsoft.CodeAnalysis.CSharp.Syntax;
    using Microsoft.CodeAnalysis.Diagnostics;

    [DiagnosticAnalyzer(LanguageNames.CSharp)]
    public class UnusedCallSpecificationAnalyzer : DiagnosticAnalyzer
    {
        public const string DiagnosticId = "UnusedCallSpecification";
        internal const string Category = "Usage";

        internal static readonly LocalizableString Title = new LocalizableResourceString(nameof(Resources.UnusedCallSpecificationTitle), Resources.ResourceManager, typeof(Resources));
        internal static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(Resources.UnusedCallSpecificationMessageFormat), Resources.ResourceManager, typeof(Resources));
        internal static readonly LocalizableString Description = new LocalizableResourceString(nameof(Resources.UnusedCallSpecificationDescription), Resources.ResourceManager, typeof(Resources));

        internal static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, description: Description);

        public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);

        public override void Initialize(AnalysisContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            context.RegisterSyntaxNodeAction(this.AnalyzeCall, SyntaxKind.InvocationExpression);
        }

        private void AnalyzeCall(SyntaxNodeAnalysisContext context)
        {
            //// Check if it's a call to A.CallTo

            var call = context.Node as InvocationExpressionSyntax;
            var memberAccess = call?.Expression as MemberAccessExpressionSyntax;

            var expr = memberAccess?.Expression as IdentifierNameSyntax;
            if (expr == null)
            {
                return;
            }

            var member = memberAccess.Name as IdentifierNameSyntax;
            if (member == null)
            {
                return;
            }

            var typeSymbol = context.SemanticModel.GetSymbolInfo(expr).Symbol as INamedTypeSymbol;
            var methodSymbol = context.SemanticModel.GetSymbolInfo(member).Symbol as IMethodSymbol;

            if (typeSymbol?.GetFullName() == "FakeItEasy.A" && methodSymbol?.Name == "CallTo")
            {
                if (call.Parent is StatementSyntax)
                {
                    var firstArg = call.ArgumentList.Arguments.FirstOrDefault();
                    var lambda = firstArg?.Expression as LambdaExpressionSyntax;
                    var callSpec = lambda?.Body?.ToString()
                                   ?? firstArg?.ToString()
                                   ?? "(unknown)";
                    var diagnostic = Diagnostic.Create(Rule, call.GetLocation(), callSpec);
                    context.ReportDiagnostic(diagnostic);
                }
            }
        }
    }
}
<commit_msg>Change analyzer diagnostic id to FakeItEasy001<commit_after>namespace FakeItEasy.Analyzer
{
    using System;
    using System.Collections.Immutable;
    using Microsoft.CodeAnalysis;
    using Microsoft.CodeAnalysis.CSharp;
    using Microsoft.CodeAnalysis.CSharp.Syntax;
    using Microsoft.CodeAnalysis.Diagnostics;

    [DiagnosticAnalyzer(LanguageNames.CSharp)]
    public class UnusedCallSpecificationAnalyzer : DiagnosticAnalyzer
    {
        public const string DiagnosticId = "FakeItEasy001";
        internal const string Category = "Usage";

        internal static readonly LocalizableString Title = new LocalizableResourceString(nameof(Resources.UnusedCallSpecificationTitle), Resources.ResourceManager, typeof(Resources));
        internal static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(Resources.UnusedCallSpecificationMessageFormat), Resources.ResourceManager, typeof(Resources));
        internal static readonly LocalizableString Description = new LocalizableResourceString(nameof(Resources.UnusedCallSpecificationDescription), Resources.ResourceManager, typeof(Resources));

        internal static readonly DiagnosticDescriptor Rule = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, description: Description);

        public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);

        public override void Initialize(AnalysisContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            context.RegisterSyntaxNodeAction(this.AnalyzeCall, SyntaxKind.InvocationExpression);
        }

        private void AnalyzeCall(SyntaxNodeAnalysisContext context)
        {
            //// Check if it's a call to A.CallTo

            var call = context.Node as InvocationExpressionSyntax;
            var memberAccess = call?.Expression as MemberAccessExpressionSyntax;

            var expr = memberAccess?.Expression as IdentifierNameSyntax;
            if (expr == null)
            {
                return;
            }

            var member = memberAccess.Name as IdentifierNameSyntax;
            if (member == null)
            {
                return;
            }

            var typeSymbol = context.SemanticModel.GetSymbolInfo(expr).Symbol as INamedTypeSymbol;
            var methodSymbol = context.SemanticModel.GetSymbolInfo(member).Symbol as IMethodSymbol;

            if (typeSymbol?.GetFullName() == "FakeItEasy.A" && methodSymbol?.Name == "CallTo")
            {
                if (call.Parent is StatementSyntax)
                {
                    var firstArg = call.ArgumentList.Arguments.FirstOrDefault();
                    var lambda = firstArg?.Expression as LambdaExpressionSyntax;
                    var callSpec = lambda?.Body?.ToString()
                                   ?? firstArg?.ToString()
                                   ?? "(unknown)";
                    var diagnostic = Diagnostic.Create(Rule, call.GetLocation(), callSpec);
                    context.ReportDiagnostic(diagnostic);
                }
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.07201800450112528, 'fraction_numerical': 0.000900225056264066, 'mean_word_length': 2.3363363363363363, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7247236', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1427, 'n_words': 337}