sjsucohort6/amigo-chatbot

View on GitHub
httpclient-common/src/main/java/edu/sjsu/amigo/http/client/HttpClient.java

Summary

Maintainability
C
1 day
Test Coverage

Method executeHttpRequestWithBody has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private Response executeHttpRequestWithBody(Map<String, String> routeParamsMap, Map<String, String> queryStringMap, Map<String, String> headersMap, Object bodyObject, HttpRequestWithBody request) throws HttpClientException {
        if (user != null && password != null) {
            request.basicAuth(user, password);
        }
        if(routeParamsMap != null) {

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method executeGetRequest has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private <T> Response executeGetRequest(Map<String, String> routeParamsMap, Map<String, String> queryStringMap, Map<String, String> headersMap, Class<T> clazz, GetRequest request) throws HttpClientException {
        if (user != null && password != null) {
            request.basicAuth(user, password);
        }

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method executeHttpRequestWithBody has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private Response executeHttpRequestWithBody(Map<String, String> routeParamsMap, Map<String, String> queryStringMap, Map<String, String> headersMap, Object bodyObject, HttpRequestWithBody request) throws HttpClientException {
        if (user != null && password != null) {
            request.basicAuth(user, password);
        }
        if(routeParamsMap != null) {

    Method executeGetRequest has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private <T> Response executeGetRequest(Map<String, String> routeParamsMap, Map<String, String> queryStringMap, Map<String, String> headersMap, Class<T> clazz, GetRequest request) throws HttpClientException {
            if (user != null && password != null) {
                request.basicAuth(user, password);
            }
    
    

      Method put has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public Response<Object> put(String url,
                            Map<String, String> routeParamsMap,
                            Map<String, String> queryStringMap,
                            Map<String, String> headersMap,
                            Object bodyObject) throws HttpClientException {

        Method executeHttpRequestWithBody has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            private Response executeHttpRequestWithBody(Map<String, String> routeParamsMap, Map<String, String> queryStringMap, Map<String, String> headersMap, Object bodyObject, HttpRequestWithBody request) throws HttpClientException {

          Method delete has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public Response<Object> delete(String url,
                                   Map<String, String> routeParamsMap,
                                   Map<String, String> queryStringMap,
                                   Map<String, String> headersMap,
                                   Object bodyObject) throws HttpClientException {

            Method executeGetRequest has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                private <T> Response executeGetRequest(Map<String, String> routeParamsMap, Map<String, String> queryStringMap, Map<String, String> headersMap, Class<T> clazz, GetRequest request) throws HttpClientException {

              Method get has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public <T> Response<T> get(String url,
                                    Map<String, String> routeParamsMap,
                                    Map<String, String> queryStringMap,
                                    Map<String, String> headersMap,
                                    Class<T> clazz) throws HttpClientException {

                Method head has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public <T> Response<T> head(String url,
                                     Map<String, String> routeParamsMap,
                                     Map<String, String> queryStringMap,
                                     Map<String, String> headersMap,
                                     Class<T> clazz) throws HttpClientException {

                  Method post has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public Response<Object> post(String url,
                                       Map<String, String> routeParamsMap,
                                       Map<String, String> queryStringMap,
                                       Map<String, String> headersMap,
                                       Object bodyObject) throws HttpClientException {

                    Method getStringFromInputStream has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private static String getStringFromInputStream(InputStream is) {
                    
                            if (is == null) return "";
                    
                            BufferedReader br = null;

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Extra separation in import group before 'java.io.*'
                    Open

                    import java.io.*;

                    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.

                    Empty line should be followed by <p> tag on the next line.</p>
                    Open

                     *

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    At-clause should have a non-empty description.
                    Open

                         * @param user

                    Empty line should be followed by <p> tag on the next line.</p>
                    Open

                     *

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    Using the '.*' form of import should be avoided - java.io.*.
                    Open

                    import java.io.*;

                    Checks that there are no import statements that use the * notation.

                    Rationale: Importing all classes from a package or staticmembers from a class leads to tight coupling between packagesor classes and might lead to problems when a new version of alibrary introduces name clashes.

                    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 228).
                    Open

                        private Response executeHttpRequestWithBody(Map<String, String> routeParamsMap, Map<String, String> queryStringMap, Map<String, String> headersMap, Object bodyObject, HttpRequestWithBody request) throws HttpClientException {

                    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.

                    At-clause should have a non-empty description.
                    Open

                         * @param passwd

                    Local variable name 'r' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
                    Open

                                Response<Object> r = new Response();

                    Checks that local, non-final variable names conform to a specified pattern.A catch parameter is considered to be a local variable.

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

                    <p> tag should be preceded with an empty line.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

                    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 107).
                    Open

                            return executeHttpRequestWithBody(routeParamsMap, queryStringMap, headersMap, bodyObject, request);

                    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 107).
                    Open

                            return executeHttpRequestWithBody(routeParamsMap, queryStringMap, headersMap, bodyObject, request);

                    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.

                    <p> tag should be preceded with an empty line.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    <p> tag should be placed immediately before the first word, with no space after.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    <p> tag should be placed immediately before the first word, with no space after.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

                    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 211).
                    Open

                        private <T> Response executeGetRequest(Map<String, String> routeParamsMap, Map<String, String> queryStringMap, Map<String, String> headersMap, Class<T> clazz, GetRequest request) throws HttpClientException {

                    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.

                    <p> tag should be preceded with an empty line.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

                    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 107).
                    Open

                            return executeHttpRequestWithBody(routeParamsMap, queryStringMap, headersMap, bodyObject, request);

                    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.

                    <p> tag should be preceded with an empty line.</p>
                    Open

                         * <p> Cases where the close operation may fail require careful

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    <p> tag should be preceded with an empty line.</p>
                    Open

                         * <p><em>Implementers of this interface are also strongly advised

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    <p> tag should be preceded with an empty line.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    <p> tag should be placed immediately before the first word, with no space after.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    Local variable name 'r' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
                    Open

                                Response<T> r = new Response();

                    Checks that local, non-final variable names conform to a specified pattern.A catch parameter is considered to be a local variable.

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

                    <p> tag should be preceded with an empty line.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    <p> tag should be placed immediately before the first word, with no space after.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    <p> tag should be preceded with an empty line.</p>
                    Open

                         * <p>While this interface method is declared to throw {@code

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    <p> tag should be placed immediately before the first word, with no space after.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    <p> tag should be preceded with an empty line.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    <p> tag should be placed immediately before the first word, with no space after.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

                    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 115).
                    Open

                        public static String getIntentFromWitAI(String message) throws UnirestException, UnsupportedEncodingException {

                    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.

                    <p> tag should be preceded with an empty line.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    <p> tag should be placed immediately before the first word, with no space after.</p>
                    Open

                         * <p> Cases where the close operation may fail require careful

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    <p> tag should be preceded with an empty line.</p>
                    Open

                         * <p>Note that unlike the {@link Closeable#close close}

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

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

                    '?' should be on a new line.
                    Open

                                r.setParsedObject(response.getBody().isArray() ?

                    <p> tag should be placed immediately before the first word, with no space after.</p>
                    Open

                         * <p>

                    Checks the Javadoc paragraph.

                    Checks that:

                    • There is one blank line between each of two paragraphs.
                    • Each paragraph but the first has <p> immediately before the first word, withno space after.

                    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