ew00github / HTTPCatClone

Recreation of http.cat
0 stars 0 forks source link

Fix formatting and remove unused variables/functions #1

Closed BradRammel closed 11 months ago

BradRammel commented 11 months ago

When you get a job people are going to nitpick the heck out of your code, so you'll want to get in the habit of writing code with decent formatting. We need good formatting because we modify existing code more than we write new code, so it shouldn't have too much excess white space or anything like that. After a quick overview it looks like you did really good with indentation though which some people struggle with. I'd start with fixing places like this. White space is good but as a general rule I wouldn't have more than one line of whitespace between lines of code, so I'd change it to something like this

 public List<HttpStatus> convert() throws IOException {
        File file = new File("src/main/resources/static/data.json");
        TypeReference<List<HttpStatus>> typeReference = new TypeReference<List<HttpStatus>>() {};

        return objectMapper.readValue(file, typeReference);
}

Another thing I noticed is that the saveAll function in HttpStatusService is unused. We can probably remove that if it's not needed since the LoadDatabase class should always save all of the status codes on startup. Or if you don't want to remove it you can create an endpoint in the controller that calls that method. So maybe something like

@GetMapping("/saveAll")
public void saveAll() {
    return HttpStatusService.saveAll();
}