Skip to content

Commit

Permalink
Address Sonarlint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Genne23v committed Nov 4, 2022
1 parent fd96f5e commit e21fed1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/FileUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Scanner;

public class FileUtilities {
static final String UTF8 = "UTF-8";
static final String MD = ".md";
static final String TXT = ".txt";
static final String HTML = ".html";
Expand Down Expand Up @@ -66,7 +67,7 @@ public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOExce
public static void createIndexFile(Options options, ArrayList<String> linkHTMLFiles) throws IOException {
File indexFile = new File(options.getOutput() + "/index.html");
FileOutputStream fs = new FileOutputStream(indexFile);
var fileWriter = new OutputStreamWriter(fs, "UTF-8");
var fileWriter = new OutputStreamWriter(fs, UTF8);

fileWriter.write(DOCTYPE);
fileWriter.write("<html lang=\"" + options.getLanguage() + "\">\n");
Expand Down Expand Up @@ -116,15 +117,15 @@ public static void createSubDirectory(String output, String filename) throws IOE

public static String[] readFile(String file) throws FileNotFoundException {
int lineNumber = 0;
Scanner scannerToCountLines = new Scanner(new File(file), "UTF-8");
Scanner scannerToCountLines = new Scanner(new File(file), UTF8);

while (scannerToCountLines.hasNextLine()) {
scannerToCountLines.nextLine();
lineNumber++;
}

String[] linesFromInputFile = new String[lineNumber];
Scanner scannerToRead = new Scanner(new File(file), "UTF-8");
Scanner scannerToRead = new Scanner(new File(file), UTF8);

int i = 0;
while (scannerToRead.hasNextLine()) {
Expand All @@ -137,7 +138,7 @@ public static String[] readFile(String file) throws FileNotFoundException {

private static String readMdFile(String file) throws FileNotFoundException {
StringBuilder bodyContent = new StringBuilder();
Scanner scanner = new Scanner(new File(file), "UTF-8");
Scanner scanner = new Scanner(new File(file), UTF8);

while (scanner.hasNextLine()) {
bodyContent.append(scanner.nextLine());
Expand Down Expand Up @@ -184,7 +185,7 @@ public static void convertTxtFile(String file, Options options, String sidebar)
String newHtmlFilename = options.getOutput() + trimFilename(file) + HTML;
File htmlFile = new File(newHtmlFilename);
FileOutputStream fs = new FileOutputStream(htmlFile);
var fileWriter = new OutputStreamWriter(fs, "UTF-8");
var fileWriter = new OutputStreamWriter(fs, UTF8);

fileWriter.write(DOCTYPE);
fileWriter.write("<html lang=\"" + options.getLanguage() + "\">\n");
Expand Down Expand Up @@ -233,7 +234,7 @@ public static void convertMdFile(String file, Options options, String sidebar) t
String newHtmlFilename = options.getOutput() + trimFilename(file) + HTML;
File htmlFile = new File(newHtmlFilename);
FileOutputStream fs = new FileOutputStream(htmlFile);
var fileWriter = new OutputStreamWriter(fs, "UTF-8");
var fileWriter = new OutputStreamWriter(fs, UTF8);

fileWriter.write(DOCTYPE);
fileWriter.write("<html lang=\"" + options.getLanguage() + "\">\n");
Expand Down
2 changes: 1 addition & 1 deletion src/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ArrayList<String> getStylesheetLinks() {
if (stylesheetLinks != null) {
return new ArrayList<>(stylesheetLinks);
}
return null;
return new ArrayList<>();
}

public void setStylesheetLinks(ArrayList<String> stylesheetLinks) {
Expand Down
3 changes: 2 additions & 1 deletion src/ParsingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

public class ParsingUtils {

private ParsingUtils() {}
private ParsingUtils() {
}

public static String getCssLinks(ArrayList<String> stylesheetLinks) {
StringBuilder cssLinks = new StringBuilder();
Expand Down

0 comments on commit e21fed1

Please sign in to comment.