@Test public void handleFirstCommitIsNotTheFirstOrdinal() throws QueryException { addSmell(thirdCommit, firstSmell); mockCommitBranch(thirdCommit, 0, 1); mockGapCommit(firstCommit.sha, 0, 0); mockLastBranchCommit(0, thirdCommit.sha); getAnalysis().query(); debugSmellInsertions(); verify(persistence, times(1)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(persistence, times(2)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, thirdCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, thirdCommit.sha, firstSmell, SmellCategory.INTRODUCTION); }
@Override public void query() throws QueryException { Smell smell; Commit previousCommit; Commit commit = Commit.empty(); Integer previousBranch; Integer currentBranch = -1; Map<String, Object> instance; while (smells.hasNext()) { instance = smells.next(); previousCommit = commit; previousBranch = currentBranch; commit = Commit.fromInstance(instance); smell = Smell.fromPaprikaInstance(instance, smellType); try { currentBranch = fetchCommitBranch(commit); } catch (BranchNotFoundException e) { logger.warn("[" + projectId + "] ==> Unable to guess branch for commit (" + commit.sha + "), skipping", e.getMessage()); continue; } if (!branchAnalyzers.containsKey(currentBranch)) { logger.debug("[" + projectId + "] => Initializing new branch: " + currentBranch); initializeBranch(currentBranch); } commit.setBranchOrdinal(fetchCommitOrdinal(currentBranch, commit)); branchAnalyzers.get(currentBranch).notifyCommit(commit); if (!previousCommit.equals(commit)) { synchronizeMergeSmells(commit, currentBranch); } branchAnalyzers.get(currentBranch).notifySmell(smell); if (!previousCommit.equals(commit) && isLastBranchCommit(previousCommit, previousBranch)) { finalizeBranch(previousBranch); branchAnalyzers.remove(previousBranch); } } for (int branchId : branchAnalyzers.keySet()) { finalizeBranch(branchId); } }
BranchAwareSmellTypeAnalysis implements Query { @Override public void query() throws QueryException { Smell smell; Commit previousCommit; Commit commit = Commit.empty(); Integer previousBranch; Integer currentBranch = -1; Map<String, Object> instance; while (smells.hasNext()) { instance = smells.next(); previousCommit = commit; previousBranch = currentBranch; commit = Commit.fromInstance(instance); smell = Smell.fromPaprikaInstance(instance, smellType); try { currentBranch = fetchCommitBranch(commit); } catch (BranchNotFoundException e) { logger.warn("[" + projectId + "] ==> Unable to guess branch for commit (" + commit.sha + "), skipping", e.getMessage()); continue; } if (!branchAnalyzers.containsKey(currentBranch)) { logger.debug("[" + projectId + "] => Initializing new branch: " + currentBranch); initializeBranch(currentBranch); } commit.setBranchOrdinal(fetchCommitOrdinal(currentBranch, commit)); branchAnalyzers.get(currentBranch).notifyCommit(commit); if (!previousCommit.equals(commit)) { synchronizeMergeSmells(commit, currentBranch); } branchAnalyzers.get(currentBranch).notifySmell(smell); if (!previousCommit.equals(commit) && isLastBranchCommit(previousCommit, previousBranch)) { finalizeBranch(previousBranch); branchAnalyzers.remove(previousBranch); } } for (int branchId : branchAnalyzers.keySet()) { finalizeBranch(branchId); } } }
BranchAwareSmellTypeAnalysis implements Query { @Override public void query() throws QueryException { Smell smell; Commit previousCommit; Commit commit = Commit.empty(); Integer previousBranch; Integer currentBranch = -1; Map<String, Object> instance; while (smells.hasNext()) { instance = smells.next(); previousCommit = commit; previousBranch = currentBranch; commit = Commit.fromInstance(instance); smell = Smell.fromPaprikaInstance(instance, smellType); try { currentBranch = fetchCommitBranch(commit); } catch (BranchNotFoundException e) { logger.warn("[" + projectId + "] ==> Unable to guess branch for commit (" + commit.sha + "), skipping", e.getMessage()); continue; } if (!branchAnalyzers.containsKey(currentBranch)) { logger.debug("[" + projectId + "] => Initializing new branch: " + currentBranch); initializeBranch(currentBranch); } commit.setBranchOrdinal(fetchCommitOrdinal(currentBranch, commit)); branchAnalyzers.get(currentBranch).notifyCommit(commit); if (!previousCommit.equals(commit)) { synchronizeMergeSmells(commit, currentBranch); } branchAnalyzers.get(currentBranch).notifySmell(smell); if (!previousCommit.equals(commit) && isLastBranchCommit(previousCommit, previousBranch)) { finalizeBranch(previousBranch); branchAnalyzers.remove(previousBranch); } } for (int branchId : branchAnalyzers.keySet()) { finalizeBranch(branchId); } } BranchAwareSmellTypeAnalysis(int projectId, Persistence persistence, Iterator<Map<String, Object>> smells,
                                 String smellType, SmellDuplicationChecker duplicationChecker,
                                 CommitQueries commitQueries, SmellQueries smellQueries, BranchQueries branchQueries); }
BranchAwareSmellTypeAnalysis implements Query { @Override public void query() throws QueryException { Smell smell; Commit previousCommit; Commit commit = Commit.empty(); Integer previousBranch; Integer currentBranch = -1; Map<String, Object> instance; while (smells.hasNext()) { instance = smells.next(); previousCommit = commit; previousBranch = currentBranch; commit = Commit.fromInstance(instance); smell = Smell.fromPaprikaInstance(instance, smellType); try { currentBranch = fetchCommitBranch(commit); } catch (BranchNotFoundException e) { logger.warn("[" + projectId + "] ==> Unable to guess branch for commit (" + commit.sha + "), skipping", e.getMessage()); continue; } if (!branchAnalyzers.containsKey(currentBranch)) { logger.debug("[" + projectId + "] => Initializing new branch: " + currentBranch); initializeBranch(currentBranch); } commit.setBranchOrdinal(fetchCommitOrdinal(currentBranch, commit)); branchAnalyzers.get(currentBranch).notifyCommit(commit); if (!previousCommit.equals(commit)) { synchronizeMergeSmells(commit, currentBranch); } branchAnalyzers.get(currentBranch).notifySmell(smell); if (!previousCommit.equals(commit) && isLastBranchCommit(previousCommit, previousBranch)) { finalizeBranch(previousBranch); branchAnalyzers.remove(previousBranch); } } for (int branchId : branchAnalyzers.keySet()) { finalizeBranch(branchId); } } BranchAwareSmellTypeAnalysis(int projectId, Persistence persistence, Iterator<Map<String, Object>> smells,
                                 String smellType, SmellDuplicationChecker duplicationChecker,
                                 CommitQueries commitQueries, SmellQueries smellQueries, BranchQueries branchQueries); @Override void query(); }
BranchAwareSmellTypeAnalysis implements Query { @Override public void query() throws QueryException { Smell smell; Commit previousCommit; Commit commit = Commit.empty(); Integer previousBranch; Integer currentBranch = -1; Map<String, Object> instance; while (smells.hasNext()) { instance = smells.next(); previousCommit = commit; previousBranch = currentBranch; commit = Commit.fromInstance(instance); smell = Smell.fromPaprikaInstance(instance, smellType); try { currentBranch = fetchCommitBranch(commit); } catch (BranchNotFoundException e) { logger.warn("[" + projectId + "] ==> Unable to guess branch for commit (" + commit.sha + "), skipping", e.getMessage()); continue; } if (!branchAnalyzers.containsKey(currentBranch)) { logger.debug("[" + projectId + "] => Initializing new branch: " + currentBranch); initializeBranch(currentBranch); } commit.setBranchOrdinal(fetchCommitOrdinal(currentBranch, commit)); branchAnalyzers.get(currentBranch).notifyCommit(commit); if (!previousCommit.equals(commit)) { synchronizeMergeSmells(commit, currentBranch); } branchAnalyzers.get(currentBranch).notifySmell(smell); if (!previousCommit.equals(commit) && isLastBranchCommit(previousCommit, previousBranch)) { finalizeBranch(previousBranch); branchAnalyzers.remove(previousBranch); } } for (int branchId : branchAnalyzers.keySet()) { finalizeBranch(branchId); } } BranchAwareSmellTypeAnalysis(int projectId, Persistence persistence, Iterator<Map<String, Object>> smells,
                                 String smellType, SmellDuplicationChecker duplicationChecker,
                                 CommitQueries commitQueries, SmellQueries smellQueries, BranchQueries branchQueries); @Override void query();  }