Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2076] Refactor RepoConfiguration to simplify constructor complexity #2078

Merged
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/java/reposense/model/CliRunConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public List<RepoConfiguration> getRepoConfigurations() throws ParseException {
List<RepoConfiguration> configs = new ArrayList<>();
for (String locationString : cliArguments.getLocations()) {
try {
configs.add(new RepoConfiguration(new RepoLocation(locationString)));
configs.add(
new RepoConfiguration.Builder()
.location(new RepoLocation(locationString))
.build()
);
} catch (InvalidLocationException ile) {
logger.log(Level.WARNING, ile.getMessage(), ile);
}
Expand Down
482 changes: 405 additions & 77 deletions src/main/java/reposense/model/RepoConfiguration.java
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For lines 38 - 39, new ArrayList<>() Initializer for ignoreGlobList and ignoredAuthorsList is now redundant

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package reposense.parser;

/**
* Signals that there was an issue building a Configuration (missing parameters, etc.).
*/
public class ConfigurationBuildException extends RuntimeException {

Check warning on line 6 in src/main/java/reposense/parser/ConfigurationBuildException.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/reposense/parser/ConfigurationBuildException.java#L6

Added line #L6 was not covered by tests

}
24 changes: 19 additions & 5 deletions src/main/java/reposense/parser/RepoConfigCsvParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,25 @@ private void addConfig(List<RepoConfiguration> results, RepoLocation location, S
boolean isIgnoredFileAnalysisSkipped, boolean isFileSizeLimitOverriding, long fileSizeLimit,
boolean isStandaloneConfigIgnored, boolean isShallowCloningPerformed,
boolean isFindingPreviousAuthorsPerformed) {
RepoConfiguration config = new RepoConfiguration(location, branch, formats, ignoreGlobList, fileSizeLimit,
isStandaloneConfigIgnored, isFileSizeLimitIgnored, ignoreCommitList, isFormatsOverriding,
isIgnoreGlobListOverriding, isIgnoreCommitListOverriding, isFileSizeLimitOverriding,
isShallowCloningPerformed, isFindingPreviousAuthorsPerformed, isIgnoredFileAnalysisSkipped,
ignoredAuthorsList, isIgnoredAuthorsListOverriding);
RepoConfiguration config = new RepoConfiguration.Builder()
.location(location)
.branch(branch)
.fileTypeManager(formats)
.ignoreGlobList(ignoreGlobList)
.fileSizeLimit(fileSizeLimit)
.isStandaloneConfigIgnored(isStandaloneConfigIgnored)
.isFileSizeLimitIgnored(isFileSizeLimitIgnored)
.ignoreCommitList(ignoreCommitList)
.isFormatsOverriding(isFormatsOverriding)
.isIgnoreGlobListOverriding(isIgnoreGlobListOverriding)
.isIgnoreCommitListOverriding(isIgnoreCommitListOverriding)
.isFileSizeLimitOverriding(isFileSizeLimitOverriding)
.isShallowCloningPerformed(isShallowCloningPerformed)
.isFindingPreviousAuthorsPerformed(isFindingPreviousAuthorsPerformed)
.isIgnoredFileAnalysisSkipped(isIgnoredFileAnalysisSkipped)
.ignoredAuthorsList(ignoredAuthorsList)
.isIgnoredAuthorsListOverriding(isIgnoredAuthorsListOverriding)
.build();

if (results.contains(config)) {
logger.warning("Ignoring duplicated repository " + location + " " + branch);
Expand Down
16 changes: 12 additions & 4 deletions src/systemtest/java/reposense/LocalRepoSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@ public class LocalRepoSystemTest {

@BeforeAll
public static void setupLocalRepos() throws Exception {
TestRepoCloner.clone(new RepoConfiguration(new RepoLocation("https://github.com/reposense/testrepo-Alpha")),
Paths.get("."), LOCAL_DIRECTORY_ONE);
TestRepoCloner.clone(new RepoConfiguration(new RepoLocation("https://github.com/reposense/testrepo-Alpha")),
Paths.get("."), LOCAL_DIRECTORY_TWO);
TestRepoCloner.clone(
new RepoConfiguration.Builder()
.location(new RepoLocation("https://github.com/reposense/testrepo-Alpha"))
.build(),
Paths.get("."), LOCAL_DIRECTORY_ONE
);
TestRepoCloner.clone(
new RepoConfiguration.Builder()
.location(new RepoLocation("https://github.com/reposense/testrepo-Alpha"))
.build(),
Paths.get("."), LOCAL_DIRECTORY_TWO
);
}

@BeforeEach
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/reposense/git/GitBranchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ public void getCurrentBranch_masterBranch_success() throws Exception {

@Test
public void getCurrentBranch_uncommonDefaultBranch_success() throws Exception {
RepoConfiguration uncommonDefaultConfig = new RepoConfiguration(
new RepoLocation(TEST_REPO_UNCOMMON_DEFAULT_GIT_LOCATION), RepoConfiguration.DEFAULT_BRANCH);
RepoConfiguration uncommonDefaultConfig = new RepoConfiguration.Builder()
.location(new RepoLocation(TEST_REPO_UNCOMMON_DEFAULT_GIT_LOCATION))
.branch(RepoConfiguration.DEFAULT_BRANCH)
.build();
uncommonDefaultConfig.setFormats(FileTypeTest.DEFAULT_TEST_FORMATS);
TestRepoCloner.cloneAndBranch(uncommonDefaultConfig);
String currentBranch = GitBranch.getCurrentBranch(uncommonDefaultConfig.getRepoRoot());
Expand Down
Loading
Loading