Fix sonar issues

This commit is contained in:
René Pfeuffer
2020-06-02 21:48:28 +02:00
parent a32bd01c45
commit 8528c0cfc1
8 changed files with 59 additions and 3 deletions

View File

@@ -56,5 +56,6 @@ public class NoneCachingWorkingCopyPool implements WorkingCopyPool {
@Override
public void shutdown() {
// no caches, nothing to clean up :-)
}
}

View File

@@ -0,0 +1,42 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.work;
import sonia.scm.ContextEntry;
import sonia.scm.ExceptionWithContext;
public class WorkdirCreationException extends ExceptionWithContext {
public static final String CODE = "3tS0mjSoo1";
public WorkdirCreationException(String path, Exception cause) {
super(ContextEntry.ContextBuilder.entity("Path", path).build(), "Could not create directory " + path, cause);
}
@Override
public String getCode() {
return CODE;
}
}

View File

@@ -47,7 +47,7 @@ public class WorkdirProvider {
try {
return Files.createTempDirectory(rootDirectory.toPath(),"workdir").toFile();
} catch (IOException e) {
throw new RuntimeException("could not create temporary workdir", e);
throw new WorkdirCreationException(rootDirectory.toString(), e);
}
}
}

View File

@@ -73,6 +73,8 @@ public class SimpleHgWorkingCopyFactory extends SimpleWorkingCopyFactory<Reposit
}
@Override
// The hg api to create a command is meant to be used from the command classes, not from their "flags" base classes.
@SuppressWarnings("java:S3252")
protected ParentAndClone<Repository, Repository> reclaim(HgCommandContext context, File target, String initialBranch) throws ReclaimFailedException {
Repository centralRepository = openCentral(context);
try {

View File

@@ -93,8 +93,9 @@ public class HgBranchCommandTest extends AbstractHgCommandTestBase {
public void shouldThrowInternalRepositoryException() {
String branchToBeClosed = "default";
new HgBranchCommand(cmdContext, workingCopyFactory).deleteOrClose(branchToBeClosed);
assertThrows(InternalRepositoryException.class, () -> new HgBranchCommand(cmdContext, workingCopyFactory).deleteOrClose(branchToBeClosed));
HgBranchCommand hgBranchCommand = new HgBranchCommand(cmdContext, workingCopyFactory);
hgBranchCommand.deleteOrClose(branchToBeClosed);
assertThrows(InternalRepositoryException.class, () -> hgBranchCommand.deleteOrClose(branchToBeClosed));
}
private List<Branch> readBranches() {

View File

@@ -50,9 +50,11 @@ public class SimpleSvnWorkingCopyFactory extends SimpleWorkingCopyFactory<File,
@Override
protected void closeRepository(File workingCopy) {
// No resources to be closed for svn
}
@Override
protected void closeWorkingCopy(File workingCopy) {
// No resources to be closed for svn
}
}

View File

@@ -219,6 +219,10 @@
"2qRyyaVcJ1": {
"displayName": "Ungültig formatiertes Element",
"description": "Die Eingabe beinhaltete unfültige Formate. Bitte prüfen Sie die Server Logs für genauere Informationen."
},
"3tS0mjSoo1": {
"displayName": "Fehler bei der Erstellung eines Arbeitsverzeichnisses",
"description": "Der Server konnte kein Arbeitsverzeichnis zur Abarbeitung der Anfrage erstellen. Bitte prüfen Sie die Server Logs für genauere Informationen."
}
},
"namespaceStrategies": {

View File

@@ -219,6 +219,10 @@
"2qRyyaVcJ1": {
"displayName": "Invalid format in element",
"description": "The input had some invalid formats. Please check the server log for further information."
},
"3tS0mjSoo1": {
"displayName": "Error creating a new working directory",
"description": "The server could not create a new working directory to process the request. Please check the server log for further information."
}
},
"namespaceStrategies": {