Skip to content

Commit

Permalink
fix some new sonar issues
Browse files Browse the repository at this point in the history
Why? After commit 58cbfe7, testing code is also checked by sonar.
  • Loading branch information
dfa1 committed Dec 22, 2023
1 parent c41fab5 commit dda4f20
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
23 changes: 23 additions & 0 deletions runtime/src/main/java/hosh/runtime/CompilerCommand.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
* MIT License
*
* Copyright (c) 2018-2023 Davide Angelocola
*
* 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 hosh.runtime;

import hosh.spi.Command;
Expand Down
1 change: 0 additions & 1 deletion spi/src/test/java/hosh/spi/RecordsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,4 @@ void prependAndAppend() {
assertThat(a.prepend(Keys.TEXT, text)).isEqualTo(a.append(Keys.TEXT, text));
assertThat(a.append(Keys.TEXT, text)).isEqualTo(a.prepend(Keys.TEXT, text));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public Path toPath() {
return folder;
}

// Sonar is reporting: "Make sure publicly writable directories are used safely here."
// since this call is used only for tests, it is fine.
@SuppressWarnings("squid::S5443")
@Override
public void beforeEach(ExtensionContext context) throws Exception {
folder = Files.createTempDirectory("hosh-");
Expand All @@ -67,7 +70,9 @@ public Path newFile(Path parent, String fileName) throws IOException {

public Path newExecutableFile(String fileName) throws IOException {
Path path = newFile(folder, fileName);
assert path.toFile().setExecutable(true);
if (!path.toFile().setExecutable(true)) {
throw new IllegalStateException("failed to set executable bit for " + path);
}
return path;
}

Expand Down

0 comments on commit dda4f20

Please sign in to comment.