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>();
PagedSearchResult
has 36 methods (exceeds 20 allowed). Consider refactoring. Open
@JsonIgnoreProperties(ignoreUnknown = true)
public class PagedSearchResult extends PagedResult<ImageResult> {
private List<ProductType> productTypes;
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;
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;
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 {
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;
RecommendSearchParams
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
public class RecommendSearchParams extends SearchParams {
private String algorithm;
private Integer altLimit;
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.
SearchByImageParam
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
public class SearchByImageParam extends BaseProductSearchParam {
public static final String POINT = "point";
/**
* Image URL
UploadSearchParams
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
public class UploadSearchParams extends BaseSearchParams<UploadSearchParams> {
private File imageFile;
private InputStream imageStream;
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 {
- Read upRead up
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.
*/
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);
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,
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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) {
- Read upRead up
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;
- Read upRead up
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"