Skip to content

Commit 840d919

Browse files
arrow1991nobodyiam
authored andcommitted
* Remove redundant local variables
1 parent 4e99205 commit 840d919

File tree

9 files changed

+21
-38
lines changed

9 files changed

+21
-38
lines changed

apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/aop/ApolloAuditSpanAspect.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ Method findMethod(ProceedingJoinPoint pjp) {
9999
parameterTypes = ((MethodSignature) pjpSignature).getParameterTypes();
100100
}
101101
try {
102-
Method method = ReflectUtils.findDeclaredMethod(clazz, methodName, parameterTypes);
103-
return method;
102+
return ReflectUtils.findDeclaredMethod(clazz, methodName, parameterTypes);
104103
} catch (NoSuchMethodException e) {
105104
return null;
106105
}

apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/component/ApolloAuditHttpInterceptor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public ClientHttpResponse intercept(HttpRequest request, byte[] body,
3737
if (traceContext.tracer() != null) {
3838
request = traceContext.tracer().inject(request);
3939
}
40-
ClientHttpResponse response = execution.execute(request, body);
41-
return response;
40+
return execution.execute(request, body);
4241
}
4342
}

apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/controller/ApolloAuditController.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,13 @@ public ApolloAuditProperties getProperties() {
5555
@GetMapping("/logs")
5656
@PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()")
5757
public List<ApolloAuditLogDTO> findAllAuditLogs(int page, int size) {
58-
List<ApolloAuditLogDTO> logDTOList = api.queryLogs(page, size);
59-
return logDTOList;
58+
return api.queryLogs(page, size);
6059
}
6160

6261
@GetMapping("/trace")
6362
@PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()")
6463
public List<ApolloAuditLogDetailsDTO> findTraceDetails(@RequestParam String traceId) {
65-
List<ApolloAuditLogDetailsDTO> detailsDTOList = api.queryTraceDetails(traceId);
66-
return detailsDTOList;
64+
return api.queryTraceDetails(traceId);
6765
}
6866

6967
@GetMapping("/logs/opName")
@@ -74,27 +72,22 @@ public List<ApolloAuditLogDTO> findAllAuditLogsByOpNameAndTime(@RequestParam Str
7472
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.S") Date startDate,
7573
@RequestParam(value = "endDate", required = false)
7674
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.S") Date endDate) {
77-
List<ApolloAuditLogDTO> logDTOList =
78-
api.queryLogsByOpName(opName, startDate, endDate, page, size);
79-
return logDTOList;
75+
return api.queryLogsByOpName(opName, startDate, endDate, page, size);
8076
}
8177

8278
@GetMapping("/logs/dataInfluences/field")
8379
@PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()")
8480
public List<ApolloAuditLogDataInfluenceDTO> findDataInfluencesByField(
8581
@RequestParam String entityName, @RequestParam String entityId,
8682
@RequestParam String fieldName, int page, int size) {
87-
List<ApolloAuditLogDataInfluenceDTO> dataInfluenceDTOList =
88-
api.queryDataInfluencesByField(entityName, entityId, fieldName, page, size);
89-
return dataInfluenceDTOList;
83+
return api.queryDataInfluencesByField(entityName, entityId, fieldName, page, size);
9084
}
9185

9286
@GetMapping("/logs/by-name-or-type-or-operator")
9387
@PreAuthorize(value = "@apolloAuditLogQueryApiPreAuthorizer.hasQueryPermission()")
9488
public List<ApolloAuditLogDTO> findAuditLogsByNameOrTypeOrOperator(@RequestParam String query,
9589
int page, int size) {
96-
List<ApolloAuditLogDTO> logDTOList = api.searchLogByNameOrTypeOrOperator(query, page, size);
97-
return logDTOList;
90+
return api.searchLogByNameOrTypeOrOperator(query, page, size);
9891
}
9992

10093
}

apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolder.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,9 @@ private GrayReleaseRuleCache transformRuleToRuleCache(GrayReleaseRule grayReleas
283283
Tracer.logError(ex);
284284
logger.error("parse rule for gray release rule {} failed", grayReleaseRule.getId(), ex);
285285
}
286-
287-
GrayReleaseRuleCache ruleCache =
288-
new GrayReleaseRuleCache(grayReleaseRule.getId(), grayReleaseRule.getBranchName(),
289-
grayReleaseRule.getNamespaceName(), grayReleaseRule.getReleaseId(),
290-
grayReleaseRule.getBranchStatus(), loadVersion.get(), ruleItems);
291-
292-
return ruleCache;
286+
return new GrayReleaseRuleCache(grayReleaseRule.getId(), grayReleaseRule.getBranchName(),
287+
grayReleaseRule.getNamespaceName(), grayReleaseRule.getReleaseId(),
288+
grayReleaseRule.getBranchStatus(), loadVersion.get(), ruleItems);
293289
}
294290

295291
private void populateDataBaseInterval() {

apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/grayReleaseRule/GrayReleaseRulesHolderTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ private GrayReleaseRuleItemDTO assembleRuleItem(String clientAppId, Set<String>
198198
private ReleaseMessage assembleReleaseMessage(String appId, String clusterName,
199199
String namespaceName) {
200200
String message = STRING_JOINER.join(appId, clusterName, namespaceName);
201-
ReleaseMessage releaseMessage = new ReleaseMessage(message);
202-
203-
return releaseMessage;
201+
return new ReleaseMessage(message);
204202
}
205203
}

apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2Test.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,7 @@ private String transformApolloConfigNotificationsToString(String namespace, long
414414

415415
private ApolloConfigNotification assembleApolloConfigNotification(String namespace,
416416
long notificationId) {
417-
ApolloConfigNotification notification = new ApolloConfigNotification(namespace, notificationId);
418-
return notification;
417+
return new ApolloConfigNotification(namespace, notificationId);
419418
}
420419

421420
private Multimap<String, String> assembleMultiMap(String key, Iterable<String> values) {

apollo-configservice/src/test/java/com/ctrip/framework/apollo/configservice/integration/NotificationControllerV2IntegrationTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,6 @@ private String transformApolloConfigNotificationsToString(String namespace, long
706706

707707
private ApolloConfigNotification assembleApolloConfigNotification(String namespace,
708708
long notificationId) {
709-
ApolloConfigNotification notification = new ApolloConfigNotification(namespace, notificationId);
710-
return notification;
709+
return new ApolloConfigNotification(namespace, notificationId);
711710
}
712711
}

apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,9 @@ public List<ReleaseDTO> findActiveReleases(String appId, Env env, String cluster
373373

374374
public ReleaseDTO loadLatestRelease(String appId, Env env, String clusterName,
375375
String namespace) {
376-
ReleaseDTO releaseDTO = restTemplate.get(env,
376+
return restTemplate.get(env,
377377
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest",
378378
ReleaseDTO.class, appId, clusterName, namespace);
379-
return releaseDTO;
380379
}
381380

382381
public ReleaseDTO createRelease(String appId, Env env, String clusterName, String namespace,
@@ -390,10 +389,9 @@ public ReleaseDTO createRelease(String appId, Env env, String clusterName, Strin
390389
parameters.add("operator", operator);
391390
parameters.add("isEmergencyPublish", String.valueOf(isEmergencyPublish));
392391
HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(parameters, headers);
393-
ReleaseDTO response = restTemplate.post(env,
392+
return restTemplate.post(env,
394393
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases", entity,
395394
ReleaseDTO.class, appId, clusterName, namespace);
396-
return response;
397395
}
398396

399397
public ReleaseDTO createGrayDeletionRelease(String appId, Env env, String clusterName,
@@ -409,10 +407,9 @@ public ReleaseDTO createGrayDeletionRelease(String appId, Env env, String cluste
409407
parameters.add("isEmergencyPublish", String.valueOf(isEmergencyPublish));
410408
grayDelKeys.forEach(key -> parameters.add("grayDelKeys", key));
411409
HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(parameters, headers);
412-
ReleaseDTO response = restTemplate.post(env,
410+
return restTemplate.post(env,
413411
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/gray-del-releases",
414412
entity, ReleaseDTO.class, appId, clusterName, namespace);
415-
return response;
416413
}
417414

418415
public ReleaseDTO updateAndPublish(String appId, Env env, String clusterName, String namespace,

apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/GlobalSearchServiceTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@
4040
import java.util.List;
4141

4242
import static org.junit.Assert.assertEquals;
43-
import static org.mockito.ArgumentMatchers.*;
44-
import static org.mockito.Mockito.*;
43+
import static org.mockito.ArgumentMatchers.any;
44+
import static org.mockito.ArgumentMatchers.anyString;
45+
import static org.mockito.ArgumentMatchers.eq;
46+
import static org.mockito.Mockito.times;
47+
import static org.mockito.Mockito.verify;
4548
import static org.mockito.Mockito.when;
4649

4750
@RunWith(MockitoJUnitRunner.class)

0 commit comments

Comments
 (0)