My code is working correctly, but is resulting in a "Assignment branch condition too high" warning with a score of 12.08 on CodeBeat.
Codebeat is an automated code review utility that helps developers write clean code. I have been using it lately in order to monitor the quality of my code since clean code is being a necessity in today's word. Codebeat calculates the complexity of the code written and assigns a score, so it seems that the complexity of this method seems a bit high that usual. I would be grateful if someone can tell me what is complex about this method.
private void populateDictionary() {
try {
Files.walkFileTree(Paths.get(rootDirectory.getCanonicalPath()), EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException {
addToDictionary(path);
return FileVisitResult.CONTINUE;
}
});
}catch(IOException e) {
System.out.println(e.getMessage());
}
System.out.println(this.indexedFileContents.keySet().size() + " files read in directory " + this.rootDirectory);
}
Can anyone tell me what am I doing wrong and how I can improve my code? Thanks in advance.