Skip to content

Commit a4efa39

Browse files
committed
apply suggestions from sonar cloud
1 parent db83548 commit a4efa39

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/main/java/org/cryptomator/cryptofs/health/shortened/NotDecodableLongName.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.cryptomator.cryptofs.health.shortened;
22

3-
import org.cryptomator.cryptofs.common.Constants;
43
import org.cryptomator.cryptofs.health.api.CommonDetailKeys;
54
import org.cryptomator.cryptofs.health.api.DiagnosticResult;
65

@@ -12,7 +11,7 @@
1211
* <p>
1312
* A string is only correct if
1413
* <ul>
15-
* <li> it ends with {@value Constants#CRYPTOMATOR_FILE_SUFFIX} and </li>
14+
* <li> it ends with {@value org.cryptomator.cryptofs.common.Constants#CRYPTOMATOR_FILE_SUFFIX} and </li>
1615
* <li> excluding the aforementioned suffix, is base64url encoded</li>
1716
* </ul>
1817
* <p>

src/main/java/org/cryptomator/cryptofs/health/shortened/ShortenedNamesCheck.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.nio.file.attribute.BasicFileAttributes;
2525
import java.util.Set;
2626
import java.util.function.Consumer;
27-
import java.util.regex.Pattern;
2827

2928
import static java.nio.charset.StandardCharsets.UTF_8;
3029
import static org.cryptomator.cryptofs.common.Constants.DEFLATED_FILE_SUFFIX;
@@ -38,7 +37,6 @@ public class ShortenedNamesCheck implements HealthCheck {
3837
private static final Logger LOG = LoggerFactory.getLogger(ShortenedNamesCheck.class);
3938
private static final int MAX_TRAVERSAL_DEPTH = 3;
4039
private static final BaseEncoding BASE64URL = BaseEncoding.base64Url();
41-
private static final Pattern NULL_BYTES = Pattern.compile("\0+");
4240

4341
@Override
4442
public String name() {
@@ -91,7 +89,7 @@ void checkShortenedName(Path dir) throws IOException {
9189
if (!attrs.isRegularFile()) {
9290
resultCollector.accept(new MissingLongName(dir));
9391
return;
94-
} else if (attrs.size() > LongFileNameProvider.MAX_FILENAME_BUFFER_SIZE) { //TODO: should be revised
92+
} else if (attrs.size() > LongFileNameProvider.MAX_FILENAME_BUFFER_SIZE) {
9593
resultCollector.accept(new ObeseNameFile(nameFile, attrs.size()));
9694
return;
9795
}
@@ -125,16 +123,16 @@ void checkShortenedName(Path dir) throws IOException {
125123
*/
126124
SyntaxResult checkSyntax(String toAnalyse) {
127125
int posObligatoryC9rString = toAnalyse.indexOf(Constants.CRYPTOMATOR_FILE_SUFFIX);
128-
if(posObligatoryC9rString == -1) {
126+
if (posObligatoryC9rString == -1) {
129127
return SyntaxResult.INVALID;
130128
}
131129

132130
var encryptedFileName = toAnalyse.substring(0, posObligatoryC9rString);
133-
if(!BASE64URL.canDecode(encryptedFileName)) {
131+
if (!BASE64URL.canDecode(encryptedFileName)) {
134132
return SyntaxResult.INVALID;
135133
}
136134

137-
if (toAnalyse.substring(posObligatoryC9rString).length() > Constants.CRYPTOMATOR_FILE_SUFFIX.length() ) {
135+
if (toAnalyse.substring(posObligatoryC9rString).length() > Constants.CRYPTOMATOR_FILE_SUFFIX.length()) {
138136
return SyntaxResult.TRAILING_BYTES;
139137
}
140138

0 commit comments

Comments
 (0)