Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #55 from rvema/lgtm-fixes
Browse files Browse the repository at this point in the history
Bug Fixes
  • Loading branch information
rvema authored Nov 15, 2019
2 parents ae184e4 + 16ee2c4 commit e1ba73a
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 98 deletions.
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ notifications:
recipients:
- tapabrata.pal@capitalone.com
- ragha.vema@capitalone.com
- nireesh.thiruveedula@capitalone.com
- Stephen.Hughes@capitalone.com
- jiyang.xu@capitalone.com
- brian.shriver@capitalone.com
- kaitlyn.heinzmann@capitalone.com
- Justin.Hoelscher@capitalone.com
- hygieia2@capitalone.com
on_success: always
on_failure: always
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</parent>

<properties>
<com.capitalone.dashboard.core.version>3.1.12</com.capitalone.dashboard.core.version>
<com.capitalone.dashboard.core.version>3.1.14</com.capitalone.dashboard.core.version>
<apache.rat.plugin.version>0.13</apache.rat.plugin.version>
<coveralls.maven.plugin.version>4.3.0</coveralls.maven.plugin.version>
<guava.version>18.0</guava.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,10 @@ public Locale getLocale() {

@Override
public void addCookie(Cookie cookie) {
if(cookie != null) {cookie.setSecure(Boolean.TRUE);}
original.addCookie(cookie);
if(cookie != null) {
cookie.setSecure(Boolean.TRUE);
original.addCookie(cookie);
}
}

@Override
Expand Down
21 changes: 9 additions & 12 deletions src/main/java/com/capitalone/dashboard/rest/FeatureController.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package com.capitalone.dashboard.rest;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;

import java.util.List;
import java.util.Optional;

import com.capitalone.dashboard.model.DataResponse;
import com.capitalone.dashboard.model.Feature;
import com.capitalone.dashboard.model.SprintEstimate;
import com.capitalone.dashboard.service.FeatureService;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.capitalone.dashboard.model.DataResponse;
import com.capitalone.dashboard.model.Feature;
import com.capitalone.dashboard.model.SprintEstimate;
import com.capitalone.dashboard.service.FeatureService;
import java.util.List;
import java.util.Optional;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.web.bind.annotation.RequestMethod.GET;

/**
* REST service managing all requests to the feature repository.
Expand Down Expand Up @@ -56,8 +55,6 @@ public DataResponse<List<Feature>> relevantStories(
* REST endpoint for retrieving all features for a given sprint and team
* (the sprint is derived)
*
* @param teamId
* A given scope-owner's source-system ID
* @return A data response list of type Feature containing all features for
* the given team and current sprint
*/
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/com/capitalone/dashboard/rest/ScopeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ public class ScopeController {
private PaginationHeaderUtility paginationHeaderUtility;

@Autowired
public ScopeController(ScopeService featureService,PaginationHeaderUtility paginationHeaderUtility) {
this.scopeService = featureService;
public ScopeController(ScopeService scopeService,PaginationHeaderUtility paginationHeaderUtility) {
this.scopeService = scopeService;
this.paginationHeaderUtility = paginationHeaderUtility;
}

/**
* REST endpoint for retrieving all features for a given sprint and team
* (the sprint is derived)
* (the sprint is derived) A given scope-owner's source-system ID
*
* @param cId
* @param scopeId
* A given scope-owner's source-system ID
* @return A data response list of type Feature containing all features for
* the given team and current sprint
*/
Expand All @@ -56,6 +56,7 @@ public DataResponse<List<Scope>> scope(
}

/**
* Return list of Teams
*
* @param collectorId
*
Expand All @@ -80,8 +81,11 @@ public List<Scope> allScopes() {
}

/**
* Return list of teams with pagination
*
* @param collectorId, search criteria, pageable
* @param collectorId
* @param descriptionFilter
* @param pageable
*
* @return List of scope
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,10 @@ private void duplicateDashboardErrorCheck(Dashboard dashboard) throws HygieiaExc
/**
* Get all dashboards filtered by title and Pageable ( default page size = 10)
*
* @param title, pageable
* @return Page<Dashboard>
* @param title Title of Dashboard
* @param type Type of Dashboard
* @param pageable Pagination Object
* @return Page<Dashboard> Page of Dashboards
*/
@Override
public Page<Dashboard> getDashboardByTitleWithFilter(String title, String type, Pageable pageable) {
Expand All @@ -796,8 +798,9 @@ public Page<Dashboard> getDashboardByTitleWithFilter(String title, String type,
/**
* Get count of all dashboards filtered by title
*
* @param title
* @return Integer
* @param title Title of Dashboard
* @param type Type of Dashboard
* @return Integer Count of Dashboards
*/
@Override
public Integer getAllDashboardsByTitleCount(String title, String type) {
Expand All @@ -813,7 +816,7 @@ public Integer getAllDashboardsByTitleCount(String title, String type) {
/**
* Get count of all dashboards, use dashboard type if supplied
*
* @param
* @param type Type of the Dashboard
* @return long
*/
@Override
Expand All @@ -828,6 +831,7 @@ public long count(String type) {
/**
* Get all dashboards with page size (default = 10)
*
* @param type Type of Dashboard
* @param page size
* @return List of dashboards
*/
Expand All @@ -842,7 +846,6 @@ public Page<Dashboard> findDashboardsByPage(String type, Pageable page) {
/**
* Get page size
*
* @param
* @return Integer
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
package com.capitalone.dashboard.service;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;

import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.capitalone.dashboard.model.Collector;
import com.capitalone.dashboard.model.CollectorItem;
import com.capitalone.dashboard.model.CollectorType;
Expand All @@ -28,6 +12,18 @@
import com.capitalone.dashboard.repository.RallyFeatureRepository;
import com.capitalone.dashboard.request.RallyFeatureRequest;
import com.capitalone.dashboard.response.RallyBurnDownResponse;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

@Service
public class RallyFeatureServiceImpl implements RallyFeatureService {
Expand Down Expand Up @@ -100,16 +96,16 @@ public RallyBurnDownResponse rallyBurnDownData(RallyFeature request) {
List<Double> taskEstimateArray = new ArrayList<>();

RallyBurnDownData burnDownData = rallyBurnDownRepository.findByIterationIdAndProjectId(request.getIterationId(),
request.getProjectId().toString());
request.getProjectId());
if(burnDownData!=null) {
for (Map<String, String> burnDownDetail : burnDownData.getBurnDownData()) {
iterationDates.add(burnDownDetail.get(RallyBurnDownData.ITERATION_DATE).substring(5, 10));
toDoHours.add(burnDownDetail.get(RallyBurnDownData.ITERATION_TO_DO_HOURS));
acceptedPoints.add(Double.parseDouble(burnDownDetail.get(RallyBurnDownData.ACCEPTED_POINTS)));
}

Double maximumTotalEstimate = burnDownData.getTotalEstimate();
Double estimateDiff = maximumTotalEstimate / (burnDownData.getBurnDownData().size() - 1);
double maximumTotalEstimate = burnDownData.getTotalEstimate();
double estimateDiff = maximumTotalEstimate / (burnDownData.getBurnDownData().size() - 1);

for (int j = 0; j < burnDownData.getBurnDownData().size(); j++) {
if (burnDownData.getBurnDownData().size() - j == 1) {
Expand All @@ -130,9 +126,4 @@ public RallyBurnDownResponse rallyBurnDownData(RallyFeature request) {

}

public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Set<Object> seen = ConcurrentHashMap.newKeySet();
return t -> seen.add(keyExtractor.apply(t));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,12 @@ && checkCommitsListForSettingPullNumber(commitsList)) {
}

private boolean checkCommitsWithPullNumber(List<Commit> commitsWithPullNumber) {
if (!CollectionUtils.isEmpty(commitsWithPullNumber)
&& (commitsWithPullNumber.size() == 1)) { return true; }

return false;
return !CollectionUtils.isEmpty(commitsWithPullNumber)
&& (commitsWithPullNumber.size() == 1);
}

private boolean checkCommitsListForSettingPullNumber(List<Commit> commitsList) {
if (!CollectionUtils.isEmpty(commitsList) && (commitsList.size() > 1)) { return true; }

return false;
return !CollectionUtils.isEmpty(commitsList) && (commitsList.size() > 1);
}

protected void setCommitPullNumber (Commit commit) {
Expand Down Expand Up @@ -294,7 +290,7 @@ protected Object getCommitNode(GitHubParsed gitHubParsed, String branch, String

ResponseEntity<String> response = null;
try {
response = restClient.makeRestCallPostGraphQL(gitHubParsed.getGraphQLUrl(), "token", token, postBody);
response = restClient.makeRestCallPost(gitHubParsed.getGraphQLUrl(), "token", token, postBody);
} catch (Exception e) {
throw new HygieiaException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public String process(JSONObject prJsonObject) throws MalformedURLException, Hyg

ResponseEntity<String> response = null;
try {
response = restClient.makeRestCallPostGraphQL(gitHubParsed.getGraphQLUrl(), "token", token, postBody);
response = restClient.makeRestCallPost(gitHubParsed.getGraphQLUrl(), "token", token, postBody);
} catch (Exception e) {
throw new HygieiaException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class SonarQubeHookServiceImpl implements SonarQubeHookService {
}

@Override
public String createFromSonarQubeV1(JSONObject request) throws ParseException, HygieiaException, MalformedURLException {
public String createFromSonarQubeV1(JSONObject request) throws ParseException {

JSONParser jsonParser = new JSONParser();
JSONObject jsonObject = (JSONObject) jsonParser.parse(request.toJSONString());
Expand Down Expand Up @@ -130,7 +130,7 @@ private void refreshData(SonarProject sonarProject, JSONObject request) {
}
}

public CodeQuality currentCodeQuality(SonarProject project, JSONObject request) {
private CodeQuality currentCodeQuality(SonarProject project, JSONObject request) {

try {
JsonParser jsonParser = new JsonParser();
Expand Down Expand Up @@ -205,45 +205,21 @@ private String strSafe(JsonObject json, String key) {
return obj == null ? "" : obj.toString();
}

private String strSafe(JSONObject json, String key) {
Object obj = json.get(key);
return obj == null ? "" : obj.toString();
}

private Integer integer(JsonObject json, String key) {
Object obj = json.get(key);
return obj == null ? null : Integer.valueOf(obj.toString().replaceAll("\"",""));
}

@SuppressWarnings("unused")
private Integer integer(JSONObject json, String key) {
Object obj = json.get(key);
return obj == null ? null : Integer.valueOf(obj.toString().replaceAll("\"",""));
}

@SuppressWarnings("unused")
private BigDecimal decimal(JSONObject json, String key) {
Object obj = json.get(key);
return obj == null ? null : new BigDecimal(obj.toString().replaceAll("\"",""));
}

@SuppressWarnings("unused")
private Boolean bool(JSONObject json, String key) {
Object obj = json.get(key);
return obj == null ? null : Boolean.valueOf(obj.toString().replaceAll("\"",""));
}

@SuppressWarnings("unused")
private String format(String duration) {
Long durationInMinutes = Long.valueOf(duration);
long durationInMinutes = Long.parseLong(duration);
if (durationInMinutes == 0) {
return "0";
}
boolean isNegative = durationInMinutes < 0;
Long absDuration = Math.abs(durationInMinutes);

int days = ((Double) ((double) absDuration / HOURS_IN_DAY / 60)).intValue();
Long remainingDuration = absDuration - (days * HOURS_IN_DAY * 60);
Long remainingDuration = absDuration - (days * HOURS_IN_DAY * 60);
int hours = ((Double) (remainingDuration.doubleValue() / 60)).intValue();
remainingDuration = remainingDuration - (hours * 60);
int minutes = remainingDuration.intValue();
Expand Down Expand Up @@ -274,10 +250,6 @@ private static void addSpaceIfNeeded(StringBuilder message) {
}
}

private JSONArray parseAsArray(JSONObject jsonObject, String key) throws ParseException {
return (JSONArray) jsonObject.get(key);
}

private static boolean displayHours(int days, int hours) {
return hours > 0 && days < 10;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/swagger/lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/, //lgtm [js/redos]
code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
br: /^ {2,}\n(?!\s*$)/,
del: noop,
Expand Down

0 comments on commit e1ba73a

Please sign in to comment.