示例#1
0
        private static int Analyze(string settings, string projectPath, string[] ignoredPaths)
        {
            var fileSystemHandler = new FileSystemHandler();
            var outputWriter      = new StandardOutputWriter();

            if (false == fileSystemHandler.Exists(settings))
            {
                outputWriter.WriteLineWithSeparator("Given settings file does not exist. Exiting...", string.Empty);

                return(SettingsFileDoesNotExistErrorCode);
            }

            if (false == fileSystemHandler.Exists(projectPath))
            {
                outputWriter.WriteLineWithSeparator("Given path to analyze does not exist. Exiting...", string.Empty);

                return(InvalidPathToAnalyzeErrorCode);
            }

            var analyzer       = new StyleCopAnalyzer();
            var projectFactory = new ProjectFactory(new FileSystemHandler());
            var project        = projectFactory.CreateFromPathWithCustomSettings(projectPath, settings, ignoredPaths);
            var violations     = analyzer.GetViolationsFromProject(project);

            var renderer = new ConsoleRenderer(outputWriter);

            renderer.RenderViolationList(violations);

            if (violations.Empty)
            {
                return(NoViolationsFound);
            }

            return(ViolationsFound);
        }
示例#2
0
 public void SetUp()
 {
     _fakeConsoleStream = new StringWriter();
     _originalOutput    = System.Console.Out;
     System.Console.SetOut(_fakeConsoleStream);
     _outputWriter = new StandardOutputWriter();
 }
示例#3
0
        private static int Analyze(string settings, string projectPath, string[] ignoredPaths)
        {
            var fileSystemHandler = new FileSystemHandler();
            var outputWriter = new StandardOutputWriter();

            if (false == fileSystemHandler.Exists(settings))
            {
                outputWriter.WriteLineWithSeparator("Given settings file does not exist. Exiting...", string.Empty);

                return SettingsFileDoesNotExistErrorCode;
            }

            if (false == fileSystemHandler.Exists(projectPath))
            {
                outputWriter.WriteLineWithSeparator("Given path to analyze does not exist. Exiting...", string.Empty);

                return InvalidPathToAnalyzeErrorCode;
            }

            var analyzer = new StyleCopAnalyzer();
            var projectFactory = new ProjectFactory(new FileSystemHandler());
            var project = projectFactory.CreateFromPathWithCustomSettings(projectPath, settings, ignoredPaths);
            var violations = analyzer.GetViolationsFromProject(project);

            var renderer = new ConsoleRenderer(outputWriter);

            renderer.RenderViolationList(violations);

            if (violations.Empty)
            {
                return NoViolationsFound;
            }

            return ViolationsFound;
        }