prasadtalasila/BITS-Darshini

View on GitHub
src/main/java/in/ac/bits/protocolanalyzer/mvc/controller/TestController.java

Summary

Maintainability
A
0 mins
Test Coverage

This block of commented-out lines of code should be removed.
Open

        TimeUnit.SECONDS.sleep(10);

Programmers should not comment out code as it bloats programs and reduces readability.

Unused code should be deleted and can be retrieved from source control history if required.

Define and throw a dedicated exception instead of using a generic one.
Open

    public void runSequentialExp()throws Exception {

Using such generic exceptions as Error, RuntimeException, Throwable, and Exception prevents calling methods from handling true, system-generated exceptions differently than application-generated errors.

Noncompliant Code Example

public void foo(String bar) throws Throwable {  // Noncompliant
  throw new RuntimeException("My Message");     // Noncompliant
}

Compliant Solution

public void foo(String bar) {
  throw new MyOwnRuntimeException("My Message");
}

Exceptions

Generic exceptions in the signatures of overriding methods are ignored, because overriding method has to follow signature of the throw declaration in the superclass. The issue will be raised on superclass declaration of the method (or won't be raised at all if superclass is not part of the analysis).

@Override
public void myMethod() throws Exception {...}

Generic exceptions are also ignored in the signatures of methods that make calls to methods that throw generic exceptions.

public void myOtherMethod throws Exception {
  doTheThing();  // this method throws Exception
}

See

This block of commented-out lines of code should be removed.
Open

        //String pcapPath = "/home/vikram/Darshini/Test_pcap_files/sample_capture_test1.pcap";

Programmers should not comment out code as it bloats programs and reduces readability.

Unused code should be deleted and can be retrieved from source control history if required.

Define and throw a dedicated exception instead of using a generic one.
Open

    public @ResponseBody String runExp(@RequestParam("pcapPath") String pcapPath)throws Exception {

Using such generic exceptions as Error, RuntimeException, Throwable, and Exception prevents calling methods from handling true, system-generated exceptions differently than application-generated errors.

Noncompliant Code Example

public void foo(String bar) throws Throwable {  // Noncompliant
  throw new RuntimeException("My Message");     // Noncompliant
}

Compliant Solution

public void foo(String bar) {
  throw new MyOwnRuntimeException("My Message");
}

Exceptions

Generic exceptions in the signatures of overriding methods are ignored, because overriding method has to follow signature of the throw declaration in the superclass. The issue will be raised on superclass declaration of the method (or won't be raised at all if superclass is not part of the analysis).

@Override
public void myMethod() throws Exception {...}

Generic exceptions are also ignored in the signatures of methods that make calls to methods that throw generic exceptions.

public void myOtherMethod throws Exception {
  doTheThing();  // this method throws Exception
}

See

Remove the non-escaped \u0009 character from this literal.
Open

        String protocolGraphStr = "graph start {\n\tethernet;\n}\ngraph ethernet {\n\tswitch(ethertype) {\n\t\tcase 0800:             ipv4;\n\t}\n}\ngraph ipv4 {\n\tswitch(protocol) {\n\t\tcase 06: tcp;\n\t}\n}\ngraph tcp {\n}\ngraph end {\n}";

Non-encoded control characters and whitespace characters are often injected in the source code because of a bad manipulation. They are either invisible or difficult to recognize, which can result in bugs when the string is not what the developer expects. If you actually need to use a control character use their encoded version (ex: ASCII \n,\t,... or Unicode U+000D, U+0009,...).

This rule raises an issue when the following characters are seen in a literal string:

No issue will be raised on the simple space character. Unicode U+0020, ASCII 32.

Noncompliant Code Example

String tabInside = "A   B";  // Noncompliant, contains a tabulation
String zeroWidthSpaceInside = "foo​bar"; // Noncompliant, it contains a U+200B character inside
char tab = '    ';

Compliant Solution

String tabInside = "A\tB";  // Compliant, uses escaped value
String zeroWidthSpaceInside = "foo\u200Bbar";  // Compliant, uses escaped value
char tab = '\t';

Exceptions

Text Blocks string literals (java 13 three double-quote marks) can contain tabulations to allow indentation using tabulations.

Remove the non-escaped \u0009 character from this literal.
Open

        String protocolGraphStr = "graph start {\n\tethernet;\n}\ngraph ethernet {\n\tswitch(ethertype) {\n\t\tcase 0800:             ipv4;\n\t}\n}\ngraph ipv4 {\n\tswitch(protocol) {\n\t\tcase 06: tcp;\n\t}\n}\ngraph tcp {\n}\ngraph end {\n}";

Non-encoded control characters and whitespace characters are often injected in the source code because of a bad manipulation. They are either invisible or difficult to recognize, which can result in bugs when the string is not what the developer expects. If you actually need to use a control character use their encoded version (ex: ASCII \n,\t,... or Unicode U+000D, U+0009,...).

This rule raises an issue when the following characters are seen in a literal string:

No issue will be raised on the simple space character. Unicode U+0020, ASCII 32.

Noncompliant Code Example

String tabInside = "A   B";  // Noncompliant, contains a tabulation
String zeroWidthSpaceInside = "foo​bar"; // Noncompliant, it contains a U+200B character inside
char tab = '    ';

Compliant Solution

String tabInside = "A\tB";  // Compliant, uses escaped value
String zeroWidthSpaceInside = "foo\u200Bbar";  // Compliant, uses escaped value
char tab = '\t';

Exceptions

Text Blocks string literals (java 13 three double-quote marks) can contain tabulations to allow indentation using tabulations.

This block of commented-out lines of code should be removed.
Open

        TimeUnit.SECONDS.sleep(10);

Programmers should not comment out code as it bloats programs and reduces readability.

Unused code should be deleted and can be retrieved from source control history if required.

Extra separation in import group before 'org.springframework.stereotype.Controller'
Open

import org.springframework.stereotype.Controller;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Extra separation in import group before 'lombok.extern.log4j.Log4j'
Open

import lombok.extern.log4j.Log4j;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Extra separation in import group before 'org.json.JSONObject'
Open

import org.json.JSONObject;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'in.ac.bits.protocolanalyzer.protocol.ProtocolChecker' import. Should be before 'org.springframework.web.context.WebApplicationContext'.
Open

import in.ac.bits.protocolanalyzer.protocol.ProtocolChecker;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 263).
Open

        String protocolGraphStr = "graph start {\n\tethernet;\n}\ngraph ethernet {\n\tswitch(ethertype) {\n\t\tcase 0800:             ipv4;\n\t}\n}\ngraph ipv4 {\n\tswitch(protocol) {\n\t\tcase 06: tcp;\n\t}\n}\ngraph tcp {\n}\ngraph end {\n}";

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'java.util.concurrent.ExecutorService' import. Should be before 'org.springframework.web.context.WebApplicationContext'.
Open

import java.util.concurrent.ExecutorService;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Extra separation in import group before 'java.util.concurrent.ExecutorService'
Open

import java.util.concurrent.ExecutorService;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 263).
Open

        String protocolGraphStr = "graph start {\n\tethernet;\n}\ngraph ethernet {\n\tswitch(ethertype) {\n\t\tcase 0800:             ipv4;\n\t}\n}\ngraph ipv4 {\n\tswitch(protocol) {\n\t\tcase 06: tcp;\n\t}\n}\ngraph tcp {\n}\ngraph end {\n}";

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 103).
Open

    public @ResponseBody String runExp(@RequestParam("pcapPath") String pcapPath)throws Exception {

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Extra separation in import group before 'in.ac.bits.protocolanalyzer.analyzer.Session'
Open

import in.ac.bits.protocolanalyzer.analyzer.Session;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'java.util.concurrent.TimeUnit' import. Should be before 'org.springframework.web.context.WebApplicationContext'.
Open

import java.util.concurrent.TimeUnit;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'java.util.concurrent.Callable' import. Should be before 'org.springframework.web.context.WebApplicationContext'.
Open

import java.util.concurrent.Callable;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 102).
Open

        //String pcapPath = "/home/vikram/Darshini/Test_pcap_files/sample_capture_test1.pcap";

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'java.util.concurrent.Executors' import. Should be before 'org.springframework.web.context.WebApplicationContext'.
Open

import java.util.concurrent.Executors;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'in.ac.bits.protocolanalyzer.analyzer.Session' import. Should be before 'org.springframework.web.context.WebApplicationContext'.
Open

import in.ac.bits.protocolanalyzer.analyzer.Session;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'in.ac.bits.protocolanalyzer.protocol.ProtocolGraphParser' import. Should be before 'org.springframework.web.context.WebApplicationContext'.
Open

import in.ac.bits.protocolanalyzer.protocol.ProtocolGraphParser;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'in.ac.bits.protocolanalyzer.protocol.Protocol' import. Should be before 'org.springframework.web.context.WebApplicationContext'.
Open

import in.ac.bits.protocolanalyzer.protocol.Protocol;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

There are no issues that match your filters.

Category
Status