Skip to content

Remove redundant code #1290

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

Merged
merged 2 commits into from
Aug 11, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public void addMergedRevision(String mergedRevision) {
}

public Set<String> getMergedRevisions() {
return mergedRevisions == null ? Collections.<String>emptySet() : mergedRevisions;
return mergedRevisions == null ? Collections.emptySet() : mergedRevisions;
}

public void setMergedRevisions(Set<String> mergedRevisions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public ScmProviderRepository getProviderRepository() {

/** {@inheritDoc} */
public String toString() {
return provider.toString() + ":" + providerRepository.toString();
return provider + ":" + providerRepository;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void testFilesListExcludes() throws IOException {

Iterator<File> it = files.iterator();
while (it.hasNext()) {
File file = (File) it.next();
File file = it.next();
if (removeBasedir(file.getAbsolutePath()).indexOf("exclude") != -1) {
fail("Found excludes in file set: " + file);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ public void execute(String scmUrl, String command, File workingDirectory, ScmVer
System.err.println("Error while executing the SCM command.");

ex.printStackTrace(System.err);

return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void execute() throws MojoExecutionException {

checkResult(result);

getLog().info("" + result.getAddedFiles().size() + " files successfully added.");
getLog().info(result.getAddedFiles().size() + " files successfully added.");

} catch (IOException | ScmException e) {
throw new MojoExecutionException("Cannot run add command : ", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,9 @@ private Date parseDate(SimpleDateFormat format, String date) throws MojoExecutio
}

try {
return format.parse(date.toString());
return format.parse(date);
} catch (ParseException e) {
throw new MojoExecutionException(
"Please use this date pattern: "
+ format.toLocalizedPattern().toString(),
e);
throw new MojoExecutionException("Please use this date pattern: " + format.toLocalizedPattern(), e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void validateConnection(String connectionString, String type) throws Moj
Iterator<String> iter = messages.iterator();

while (iter.hasNext()) {
getLog().error(iter.next().toString());
getLog().error(iter.next());
}

getLog().error("The invalid scm url connection: '" + connectionString + "'.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public HgAddConsumer(File workingDir) {

/** {@inheritDoc} */
public void doConsume(ScmFileStatus status, String trimmedLine) {
if (status != null && status == ScmFileStatus.ADDED) {
if (status == ScmFileStatus.ADDED) {
// Only include real files (not directories)
File tmpFile = new File(workingDir, trimmedLine);
if (!tmpFile.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public HgRemoveConsumer(File workingDir) {

/** {@inheritDoc} */
public void doConsume(ScmFileStatus status, String trimmedLine) {
if (status != null && status == ScmFileStatus.DELETED) {
if (status == ScmFileStatus.DELETED) {
// Only include real files (not directories)
File tmpFile = new File(workingDir, trimmedLine);
if (!tmpFile.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void testDeletion() throws Exception {
Iterator<ScmFile> files = new TreeSet<ScmFile>(updatedFiles).iterator();

// readme.txt
ScmFile file = (ScmFile) files.next();
ScmFile file = files.next();
assertPath("/readme.txt", file.getPath());
assertTrue(file.getStatus().isUpdate());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public void consumeLine(String line) {
logger.warn("Unparseable line: '" + line + "'");
}
patch.append(line).append("\n");
return;
} else if (line.startsWith(INDEX_LINE_TOKEN)) {
// skip, though could parse to verify start revision and end revision
patch.append(line).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private Commandline createCloneCommand(
gitClone.createArg().setValue("1");
}

if (version != null && (version instanceof ScmBranch)) {
if (version instanceof ScmBranch) {

gitClone.createArg().setValue("--branch");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ public void consumeLine(String line) {
if (logger.isInfoEnabled()) {
logger.info("could not parse line: " + line);
}

return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ public static Commandline createLatestRevisionCommandLine(
// same as --topo-order, but ensure ordering of merges
cl.createArg().setValue("--date-order");

if (scmVersion != null
&& scmVersion instanceof ScmBranch
if (scmVersion instanceof ScmBranch
&& scmVersion.getName() != null
&& scmVersion.getName().length() > 0) {
// if any branch is given, lets take em
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public void testLog1Consumer() throws Exception {

assertEquals(2, changedFiles.size());

testScmFile((ScmFile) changedFiles.get(0), "src/main/java/Application.java", ScmFileStatus.DELETED);
testScmFile((ScmFile) changedFiles.get(1), "src/test/java/Test.java", ScmFileStatus.DELETED);
testScmFile(changedFiles.get(0), "src/main/java/Application.java", ScmFileStatus.DELETED);
testScmFile(changedFiles.get(1), "src/test/java/Test.java", ScmFileStatus.DELETED);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected Commandline createCommandLine(
Iterator<File> it = fileSet.getFileList().iterator();

while (it.hasNext()) {
File file = (File) it.next();
File file = it.next();

if (repository == null) {
cl.createArg().setValue(file.getPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public void consumeLine(String line) {
String revisionString = line.substring(COMMITTED_REVISION_TOKEN.length() + 1, line.length() - 1);

revision = Integer.parseInt(revisionString);

return;
} else if (statusString.equals("A")) {
String file = line.substring(3);

Expand All @@ -62,8 +60,6 @@ public void consumeLine(String line) {
if (logger.isInfoEnabled()) {
logger.info("Unknown line: '" + line + "'");
}

return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.maven.scm.ScmBranch;
import org.apache.maven.scm.ScmBranchParameters;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFile;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmTagParameters;
import org.apache.maven.scm.ScmVersion;
Expand Down Expand Up @@ -115,8 +114,8 @@ public class ScmProviderStub implements ScmProvider {
*/
public ScmProviderStub() {
setScmSpecificFilename("");
setAddScmResult(new AddScmResult("", Collections.<ScmFile>emptyList()));
setBranchScmResult(new BranchScmResult("", Collections.<ScmFile>emptyList()));
setAddScmResult(new AddScmResult("", Collections.emptyList()));
setBranchScmResult(new BranchScmResult("", Collections.emptyList()));
setChangeLogScmResult(new ChangeLogScmResult("", "", "", true));
setCheckInScmResult(new CheckInScmResult("", "", "", true));
setCheckOutScmResult(new CheckOutScmResult("", "", "", true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void testCheckOutCommandTest() throws Exception {
for (Iterator<ScmFile> it = files.iterator(); it.hasNext(); i++) {
ScmFile scmFile = it.next();

System.out.println("" + i + ": " + scmFile);
System.out.println(i + ": " + scmFile);
}

fail("Expected 4 files in the updated files list, was " + checkedOutFiles.size());
Expand Down
Loading