Esempio n. 1
0
        public void TestCli()
        {
            string mvcMusicStorePath = Directory.EnumerateFiles(tempDir, "MvcMusicStore.sln", SearchOption.AllDirectories).FirstOrDefault();

            string[]    args = { "-p", mvcMusicStorePath };
            AnalyzerCLI cli  = new AnalyzerCLI();

            cli.HandleCommand(args);
            Assert.NotNull(cli);
            Assert.NotNull(cli.FilePath);
            Assert.NotNull(cli.Project);
            Assert.NotNull(cli.Configuration);
        }
Esempio n. 2
0
        private static CodeAnalyzer GetDefaultCodeAnalyzer(string solutionOrProjectPath)
        {
            // Codelyzer input
            var analyzerOutputDir = Path.Combine("..", "..");

            /* 1. Logger object */
            var logger = Log.Logger;

            /* 2. Get Analyzer instance based on language */
            var args = new[]
            {
                "-p", solutionOrProjectPath
            };
            AnalyzerCLI cli = new AnalyzerCLI();

            cli.HandleCommand(args);
            cli.Configuration = new AnalyzerConfiguration(LanguageOptions.CSharp)
            {
                ExportSettings =
                {
                    GenerateJsonOutput = false,
                    OutputPath         = analyzerOutputDir
                },

                MetaDataSettings =
                {
                    LiteralExpressions    = true,
                    MethodInvocations     = true,
                    Annotations           = true,
                    LambdaMethods         = true,
                    DeclarationNodes      = true,
                    LocationData          = true,
                    ReferenceData         = true,
                    LoadBuildData         = true,
                    ReturnStatements      = true,
                    InterfaceDeclarations = true
                }
            };

            return(CodeAnalyzerFactory.GetAnalyzer(cli.Configuration, logger));
        }
Esempio n. 3
0
        private CodeAnalyzer GetDefaultCodeAnalyzer()
        {
            var analyzerOutputDir = Path.Combine("..", "..");
            var cli = new AnalyzerCLI
            {
                Configuration = new AnalyzerConfiguration(LanguageOptions.CSharp)
                {
                    ExportSettings =
                    {
                        GenerateJsonOutput = true,
                        OutputPath         = analyzerOutputDir
                    },

                    MetaDataSettings =
                    {
                        LiteralExpressions    = true,
                        MethodInvocations     = true,
                        Annotations           = true,
                        LambdaMethods         = true,
                        DeclarationNodes      = true,
                        LocationData          = true,
                        ReferenceData         = true,
                        LoadBuildData         = true,
                        InterfaceDeclarations = true
                    }
                }
            };

            Logger.LogInformation("Creating default CodeAnalyzer with the following parameters:");
            Logger.LogInformation(cli.Project + " -- " + cli.FilePath);
            Logger.LogInformation(SerializeUtils.ToJson(cli.Configuration));

            /* Get Analyzer instance based on language */
            var analyzer = CodeAnalyzerFactory.GetAnalyzer(cli.Configuration, Logger);

            return(analyzer);
        }