There are more than 100 tools available. I found the best among them.
Tool: https://pmd.github.io/
Usage
Tool: https://pmd.github.io/
Usage
$ cd $HOME
$ curl -OL https://github.com/pmd/pmd/releases/download/pmd_releases%2F5.8.1/pmd-bin-5.8.1.zip
$ unzip pmd-bin-5.8.1.zip
$ alias pmd="$HOME/pmd-bin-5.8.1/bin/run.sh pmd"
$ pmd -d <your java src location> -R java-basic -f text
[Example] $ pmd-bin-5.8.1/bin/run.sh pmd -dir /opt/science/mycode/src -f text -rulesets java-basic,java-design