public void NOCTester(string treeKey) { SyntaxTree tree = _treeDictionary[treeKey]; int result = int.Parse(treeKey.Split("-")[0]); CSharpCompilation compilation = CSharpCompilation.Create("Trivial") .AddReferences( MetadataReference.CreateFromFile( typeof(object).Assembly.Location)) .AddSyntaxTrees(tree); SemanticModel model = compilation.GetSemanticModel(tree); IEnumerable <ClassDeclarationSyntax> classDeclarations = MetricRunner.GetClassesFromRoot(tree.GetRoot()); var outgoingCouplings = CouplingBetweenObjects.CalculateCouplings(new List <SyntaxTree> { tree }, compilation); int noc = CouplingBetweenObjects.GetCount(classDeclarations.First(), model, outgoingCouplings); Assert.IsTrue(noc == result); }
public void RfcTester(string treeKey) { SyntaxTree tree = _treeDictionary[treeKey]; int result = int.Parse(treeKey.Split('-')[0]); IEnumerable <ClassDeclarationSyntax> classDeclarations = MetricRunner.GetClassesFromRoot(tree.GetRoot()); int rfc = ResponseForAClass.GetCount(classDeclarations.First()); Assert.IsTrue(rfc == result); }
static void Main(string[] args) { Console.WriteLine("Repository Analyzer"); Console.WriteLine("Select target project"); TargetProject[] targetProjects = TargetProject.GetTargetProjects(); for (int i = 0; i < targetProjects.Length; i++) { Console.WriteLine($@"[{(char)('A' + i) }]: {targetProjects[i].OrganizationName}/{targetProjects[i].RepositoryName}"); } Console.Write("Please enter project #: "); var input = Console.ReadKey().KeyChar; int choice = char.ToUpper(input) - 65; Console.WriteLine(); TargetProject targetProject = targetProjects[choice]; IIssueTrackerService issueTrackerService; if (targetProject.RepositoryName == "knowNow") { issueTrackerService = new TfsService($@"{RepositoriesFolder}/{targetProject.RepositoryName}");; } else { issueTrackerService = new GithubService(targetProject); } string solutionFile = $@"{RepositoriesFolder}/{targetProject.RepositoryName}/{targetProject.SolutionFileLocation}"; _repository = targetProject.RepositoryName; _shellService = new ShellService($@"{RepositoriesFolder}/{_repository}"); // _shellService.CheckoutCommit(); var hash = _shellService.GetHeadHash(); RepositoryWithMetrics repositoryWithMetrics = new RepositoryWithMetrics(); MetricRunner runner = new MetricRunner(solutionFile); SolutionVersionWithMetrics solutionVersionWithMetrics = runner.GetSolutionVersionWithMetrics().Result; repositoryWithMetrics.AddVersion("HEAD", solutionVersionWithMetrics); List <FaultyVersion> faultyVersions = issueTrackerService.GetFaultyVersions(); Dictionary <string, int> bugAmountInClasses = GetBugAmountInClasses(faultyVersions); List <OutputRow> output = GetOutput(solutionVersionWithMetrics.ClassesWithMetrics, bugAmountInClasses); OutputCsv(output, $@"C:\Users\BartZ\code-analysis-results\{targetProject.OrganizationName}_{_repository}_{hash}_complete.csv"); Console.ReadKey(); }
public void NocTester(string treeKey) { SyntaxTree tree = _treeDictionary[treeKey]; int result = int.Parse(treeKey.Split("-")[0]); CSharpCompilation compilation = CSharpCompilation.Create("Trivial") .AddReferences( MetadataReference.CreateFromFile( typeof(object).Assembly.Location)) .AddSyntaxTrees(tree); SemanticModel model = compilation.GetSemanticModel(tree); IEnumerable <ClassDeclarationSyntax> classDeclarations = MetricRunner.GetClassesFromRoot(tree.GetRoot()); Dictionary <INamedTypeSymbol, int> classExtensions = NumberOfChildren.GetClassExtensions(new List <SyntaxTree> { tree }, compilation); int noc = NumberOfChildren.GetCount(classDeclarations.First(), model, classExtensions); Assert.IsTrue(noc == result); }