visenze/visearch-sdk-java

View on GitHub

Showing 63 of 68 total issues

BaseSearchParams has 55 methods (exceeds 20 allowed). Consider refactoring.
Open

public class BaseSearchParams<P extends BaseSearchParams<P>> {

    private static final List<String> DEFAULT_FACET_FIELD = Lists.newArrayList();
    private static final Boolean DEFAULT_SCORE = false;
    private static final Map<String, String> DEFAULT_FQ = new HashMap<String, String>();
Severity: Major
Found in src/main/java/com/visenze/visearch/BaseSearchParams.java - About 7 hrs to fix

    PagedSearchResult has 36 methods (exceeds 20 allowed). Consider refactoring.
    Open

    @JsonIgnoreProperties(ignoreUnknown = true)
    public class PagedSearchResult extends PagedResult<ImageResult> {
    
        private List<ProductType> productTypes;
    
    
    Severity: Minor
    Found in src/main/java/com/visenze/visearch/PagedSearchResult.java - About 4 hrs to fix

      ObjectSearchResult has 32 methods (exceeds 20 allowed). Consider refactoring.
      Open

      @JsonIgnoreProperties(ignoreUnknown = true)
      public class ObjectSearchResult {
          private String type;
          private Float score;
          private Float rerankScore;
      Severity: Minor
      Found in src/main/java/com/visenze/visearch/ObjectSearchResult.java - About 4 hrs to fix

        File SearchOperationsImpl.java has 333 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        package com.visenze.visearch.internal;
        
        import com.fasterxml.jackson.core.JsonProcessingException;
        import com.fasterxml.jackson.databind.JsonNode;
        import com.fasterxml.jackson.databind.ObjectMapper;
        Severity: Minor
        Found in src/main/java/com/visenze/visearch/internal/SearchOperationsImpl.java - About 4 hrs to fix

          Method getPagedResult has 98 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private PagedSearchResult getPagedResult(ViSearchHttpResponse httpResponse) {
                  String response = httpResponse.getBody();
                  Map<String, String> headers = httpResponse.getHeaders();
                  JsonNode node;
                  try {
          Severity: Major
          Found in src/main/java/com/visenze/visearch/internal/SearchOperationsImpl.java - About 3 hrs to fix

            File BaseSearchParams.java has 308 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            package com.visenze.visearch;
            
            import com.google.common.base.Joiner;
            import com.google.common.base.Optional;
            import com.google.common.base.Preconditions;
            Severity: Minor
            Found in src/main/java/com/visenze/visearch/BaseSearchParams.java - About 3 hrs to fix

              RecommendSearchParams has 28 methods (exceeds 20 allowed). Consider refactoring.
              Open

              public class RecommendSearchParams extends SearchParams {
              
                  private String algorithm;
              
                  private Integer altLimit;
              Severity: Minor
              Found in src/main/java/com/visenze/visearch/RecommendSearchParams.java - About 3 hrs to fix

                ProductSearchResponse has 26 methods (exceeds 20 allowed). Consider refactoring.
                Open

                @JsonIgnoreProperties(ignoreUnknown = true)
                public class ProductSearchResponse extends BaseProductSearchResponse {
                
                    /**
                     * Image ID. Can be used to search again without re-uploading.
                Severity: Minor
                Found in src/main/java/com/visenze/productsearch/ProductSearchResponse.java - About 3 hrs to fix

                  SearchByImageParam has 25 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  public class SearchByImageParam extends BaseProductSearchParam {
                  
                      public static final String POINT = "point";
                      /**
                       * Image URL
                  Severity: Minor
                  Found in src/main/java/com/visenze/productsearch/param/SearchByImageParam.java - About 2 hrs to fix

                    UploadSearchParams has 24 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    public class UploadSearchParams extends BaseSearchParams<UploadSearchParams> {
                    
                    
                        private File imageFile;
                        private InputStream imageStream;
                    Severity: Minor
                    Found in src/main/java/com/visenze/visearch/UploadSearchParams.java - About 2 hrs to fix

                      Method getPagedResult has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private PagedSearchResult getPagedResult(ViSearchHttpResponse httpResponse) {
                              String response = httpResponse.getBody();
                              Map<String, String> headers = httpResponse.getHeaders();
                              JsonNode node;
                              try {
                      Severity: Minor
                      Found in src/main/java/com/visenze/visearch/internal/SearchOperationsImpl.java - About 2 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

                      SearchByIdParam has 23 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      public class SearchByIdParam extends BaseProductSearchParam {
                          /**
                           * Product ID returned by other API. Will be used to append to visual
                           * similar search path.
                           */
                      Severity: Minor
                      Found in src/main/java/com/visenze/productsearch/param/SearchByIdParam.java - About 2 hrs to fix

                        File BaseProductSearchParam.java has 269 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        package com.visenze.productsearch.param;
                        
                        import com.google.common.base.Optional;
                        import com.google.common.collect.*;
                        
                        

                          ObjectProductResult has 21 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          @JsonIgnoreProperties(ignoreUnknown = true)
                          public class ObjectProductResult {
                          
                              @JsonProperty("type")
                              private String type;

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

                                public Multimap<String, String> toMap() {
                                    Multimap<String, String> map = LinkedHashMultimap.create();
                            
                                    putIfPresent(map, page, PAGE);
                                    putIfPresent(map, limit, LIMIT);
                            Severity: Minor
                            Found in src/main/java/com/visenze/visearch/BaseSearchParams.java - About 1 hr to fix

                              Similar blocks of code found in 2 locations. Consider refactoring.
                              Open

                                  public InsertStatusMixin(@JsonProperty("trans_id") String transId,
                                                           @JsonProperty("processed_percent") Integer processedPercent,
                                                           @JsonProperty("total") Integer total,
                                                           @JsonProperty("success_count") Integer successCount,
                                                           @JsonProperty("fail_count") Integer failCount,
                              src/main/java/com/visenze/visearch/InsertStatus.java on lines 22..36

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 115.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Similar blocks of code found in 2 locations. Consider refactoring.
                              Open

                                  public InsertStatus(String transId, Integer processedPercent,
                                                      Integer total, Integer successCount, Integer failCount,
                                                      Date startTime, Date updateTime,
                                                      List<InsertError> errorList, Integer errorPage, Integer errorLimit) {
                                      this.transId = transId;
                              Severity: Major
                              Found in src/main/java/com/visenze/visearch/InsertStatus.java and 1 other location - About 1 hr to fix
                              src/main/java/com/visenze/visearch/internal/json/InsertStatusMixin.java on lines 24..44

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 115.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

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

                                  private InsertStatus parseInsertStatus(String response, Map<String, String> headers) {
                                      try {
                                          JsonNode responseNode = objectMapper.readTree(response);
                                          JsonNode statusNode = responseNode.get("status");
                                          if (statusNode == null) {
                              Severity: Minor
                              Found in src/main/java/com/visenze/visearch/internal/DataOperationsImpl.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 getAutoCompleteResult has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private AutoCompleteResult getAutoCompleteResult(ViSearchHttpResponse httpResponse) {
                                      String rawResponse = httpResponse.getBody();
                                      Map<String, String> headers = httpResponse.getHeaders();
                                      JsonNode node;
                              
                              

                                Method pagify has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    protected PagedSearchResult pagify(String rawResponse, JsonNode node) {
                                
                                        List<ImageResult> result = new ArrayList<ImageResult>();
                                        List<ObjectSearchResult> objects = null;
                                        List<GroupSearchResult> groupResults = 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

                                Severity
                                Category
                                Status
                                Source
                                Language