apimatic/okhttp-client-adapter

View on GitHub

Showing 10 of 10 total issues

Method convertRequest has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    private okhttp3.Request convertRequest(final Request httpRequest) {
        okhttp3.RequestBody requestBody;

        if (httpRequest.getBody() != null) {

Severity: Minor
Found in src/main/java/io/apimatic/okhttpclient/adapter/OkClient.java - About 5 hrs to fix

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

File OkClient.java has 348 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package io.apimatic.okhttpclient.adapter;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
Severity: Minor
Found in src/main/java/io/apimatic/okhttpclient/adapter/OkClient.java - About 4 hrs to fix

    Method intercept has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        public Response intercept(Chain it) throws IOException {
            Request request = it.request();
            Response response = null;
            try {

    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 convertRequest has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private okhttp3.Request convertRequest(final Request httpRequest) {
            okhttp3.RequestBody requestBody;
    
            if (httpRequest.getBody() != null) {
    
    
    Severity: Major
    Found in src/main/java/io/apimatic/okhttpclient/adapter/OkClient.java - About 2 hrs to fix

      Method createMultipartRequestBody has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private okhttp3.RequestBody createMultipartRequestBody(Request httpRequest) {
              okhttp3.MultipartBody.Builder multipartBuilder =
                      new okhttp3.MultipartBody.Builder().setType(okhttp3.MultipartBody.FORM);
      
              for (SimpleEntry<String, Object> param : httpRequest.getParameters()) {
      Severity: Minor
      Found in src/main/java/io/apimatic/okhttpclient/adapter/OkClient.java - About 1 hr to fix

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

            @Override
            public okhttp3.Response intercept(Chain chain) throws IOException {
        
                okhttp3.Request request = chain.request();
                RequestState requestState = getRequestState(request);

        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 intercept has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public Response intercept(Chain it) throws IOException {
                Request request = it.request();
                Response response = null;
                try {

          Method intercept has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Override
              public okhttp3.Response intercept(Chain chain) throws IOException {
          
                  okhttp3.Request request = chain.request();
                  RequestState requestState = getRequestState(request);

            Method createMultipartRequestBody has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                private okhttp3.RequestBody createMultipartRequestBody(Request httpRequest) {
                    okhttp3.MultipartBody.Builder multipartBuilder =
                            new okhttp3.MultipartBody.Builder().setType(okhttp3.MultipartBody.FORM);
            
                    for (SimpleEntry<String, Object> param : httpRequest.getParameters()) {
            Severity: Minor
            Found in src/main/java/io/apimatic/okhttpclient/adapter/OkClient.java - About 1 hr to fix

            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 publishResponse has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                private Response publishResponse(final okhttp3.Response okHttpResponse,
                        final Request httpRequest, final CompletableFuture<Response> completionBlock,
                        final Throwable error, final boolean hasBinaryResponse) {
            Severity: Minor
            Found in src/main/java/io/apimatic/okhttpclient/adapter/OkClient.java - About 35 mins to fix
              Severity
              Category
              Status
              Source
              Language