File InputsUtil.java
has 444 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* Copyright 2019-2024 Open Text
* This program and the accompanying materials
* are made available under the terms of the Apache License v2.0 which accompany this distribution.
*
InputsUtil
has 42 methods (exceeds 20 allowed). Consider refactoring. Open
public final class InputsUtil {
private static final String ACTION = "Action";
private static final String ASSOCIATE_PUBLIC_IP_ADDRESS = "AssociatePublicIpAddress";
private static final String CANONICAL_HEADER_CONTENT_SHA = "x-amz-content-sha256";
private static final String GP2 = "gp2";
Method getQueryParamsSpecificString
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public static String getQueryParamsSpecificString(String specificArea, int index) {
if (AVAILABILITY_ZONES.equalsIgnoreCase(specificArea)) {
return AVAILABILITY_ZONES + FIXED_PREFIX + valueOf(index + ONE);
} else if (NETWORK.equalsIgnoreCase(specificArea)) {
return PRIVATE_IP_ADDRESSES + DOT + valueOf(index + ONE) + DOT;
- 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 getQueryParamsSpecificString
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static String getQueryParamsSpecificString(String specificArea, int index) {
if (AVAILABILITY_ZONES.equalsIgnoreCase(specificArea)) {
return AVAILABILITY_ZONES + FIXED_PREFIX + valueOf(index + ONE);
} else if (NETWORK.equalsIgnoreCase(specificArea)) {
return PRIVATE_IP_ADDRESSES + DOT + valueOf(index + ONE) + DOT;
Method getValidEbsSize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static String getValidEbsSize(String input, String ebsType) {
if (NOT_RELEVANT.equalsIgnoreCase(input)) {
return NOT_RELEVANT;
}
switch (ebsType) {
- 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 setNetworkInterfaceSpecificQueryParams
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void setNetworkInterfaceSpecificQueryParams(Map<String, String> queryParamsMap, InputsWrapper wrapper,
String[] referenceArray, int index) {
if (isNotBlank(wrapper.getNetworkInputs().getNetworkInterfaceDescription())) {
setSpecificQueryParamValue(queryParamsMap, referenceArray,
wrapper.getNetworkInputs().getNetworkInterfaceDescription(),
Method setSpecificBooleanQueryParam
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
private static void setSpecificBooleanQueryParam(Map<String, String> queryParamsMap, String[] referenceArray,
String inputString, String referenceInputName, String currentInputName,
String suffix, String delimiter, int index, boolean enforcedBoolean) {
Method getValidEbsSize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static String getValidEbsSize(String input, String ebsType) {
if (NOT_RELEVANT.equalsIgnoreCase(input)) {
return NOT_RELEVANT;
}
switch (ebsType) {
Method setSpecificQueryParamValue
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
private static void setSpecificQueryParamValue(Map<String, String> queryParamsMap, String[] referenceArray,
String inputString, String referenceInputName, String currentInputName,
String suffix, String delimiter, int index) {
Method getValidKeyOrValueTag
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public static String getValidKeyOrValueTag(String input, String pattern, boolean isKey, boolean condition,
boolean patternCheck, int keyMaxLength, int valueMaxLength) {
Method getValidStringArray
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private static String[] getValidStringArray(String[] referenceArray, String inputString, String condition,
String delimiter, String firstInputName, String secondInputName) {
Method getValidKeyOrValueTag
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static String getValidKeyOrValueTag(String input, String pattern, boolean isKey, boolean condition,
boolean patternCheck, int keyMaxLength, int valueMaxLength) {
if (isKey && (condition || input.length() > keyMaxLength)) {
throw new RuntimeException(getValidationException(input, false));
} else if (!isKey && input.length() > valueMaxLength) {
- 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 getValidInt
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private static int getValidInt(String input, int minAllowed, int maxAllowed, String noIntError, String constrainsError) {
Method getHeadersOrQueryParamsMap
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static Map<String, String> getHeadersOrQueryParamsMap(Map<String, String> inputMap, String stringToSplit,
String delimiter, String customDelimiter, boolean trim) {
Method setTypicalQueryParams
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static void setTypicalQueryParams(Map<String, String> inputMap, String inputString, String inputName,
String prefix, String delimiter) {
Avoid too many return
statements within this method. Open
return SECURITY_GROUP_NAME_CONST + DOT + (index + ONE);
Avoid too many return
statements within this method. Open
return LISTENERS + FIXED_PREFIX+ valueOf(index + ONE) + DOT;
Avoid too many return
statements within this method. Open
return BLOCK_DEVICE_MAPPING + DOT + valueOf(index + ONE) + DOT;
Avoid too many return
statements within this method. Open
return SUBNET_ID + DOT + valueOf(index + ONE) ;
Avoid too many return
statements within this method. Open
return NETWORK_INTERFACE + DOT + valueOf(index + ONE) + DOT + PRIVATE_IP_ADDRESSES + DOT + valueOf(index + ONE) + DOT;
Avoid too many return
statements within this method. Open
return ZONE_NAME + DOT + valueOf(index + ONE);
Avoid too many return
statements within this method. Open
return REGION_NAME + DOT + valueOf(index + ONE);
Avoid too many return
statements within this method. Open
return FILTER + DOT + valueOf(index + ONE) + DOT + VALUE;
Avoid too many return
statements within this method. Open
return BLOCK_DEVICE_MAPPING + DOT + valueOf(index + ONE) + DOT + EBS + DOT;
Avoid too many return
statements within this method. Open
return PRIVATE_IP_ADDRESSES + DOT + valueOf(index + ONE) + DOT;
Avoid too many return
statements within this method. Open
return SECURITY_GROUP_ID_CONST + DOT + (index + ONE);
Avoid too many return
statements within this method. Open
return TAG + DOT + valueOf(index + ONE) + DOT + KEY;
Avoid too many return
statements within this method. Open
return FILTER + DOT + valueOf(index + ONE) + DOT + NAME;
Avoid too many return
statements within this method. Open
return AVAILABILITY_ZONES + FIXED_PREFIX + valueOf(index + ONE);
Avoid too many return
statements within this method. Open
return TAG + DOT + valueOf(index + ONE) + DOT + VALUE;
Avoid too many return
statements within this method. Open
return RESOURCE_ID + DOT + valueOf(index + ONE);
Method setNetworkInterfaceSpecificQueryParams
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static void setNetworkInterfaceSpecificQueryParams(Map<String, String> queryParamsMap, InputsWrapper wrapper,
String[] referenceArray, int index) {
if (isNotBlank(wrapper.getNetworkInputs().getNetworkInterfaceDescription())) {
setSpecificQueryParamValue(queryParamsMap, referenceArray,
wrapper.getNetworkInputs().getNetworkInterfaceDescription(),
- 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 getHeadersOrQueryParamsMap
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static Map<String, String> getHeadersOrQueryParamsMap(Map<String, String> inputMap, String stringToSplit,
String delimiter, String customDelimiter, boolean trim) {
String[] headersOrParamsArray = stringToSplit.split(delimiter);
String[] values;
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (isNotBlank(wrapper.getNetworkInputs().getNetworkInterfaceDeleteOnTermination())) {
setSpecificBooleanQueryParam(queryParamsMap, referenceArray,
wrapper.getNetworkInputs().getNetworkInterfaceDeleteOnTermination(),
PRIVATE_IP_ADDRESSES_STRING, NETWORK_INTERFACE_DELETE_ON_TERMINATION, DELETE_ON_TERMINATION,
wrapper.getCommonInputs().getDelimiter(), index, true);
- 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 42.
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
if (isNotBlank(wrapper.getNetworkInputs().getNetworkInterfacesAssociatePublicIpAddressesString())) {
setSpecificBooleanQueryParam(queryParamsMap, referenceArray,
wrapper.getNetworkInputs().getNetworkInterfacesAssociatePublicIpAddressesString(),
PRIVATE_IP_ADDRESSES_STRING, NETWORK_INTERFACE_ASSOCIATE_PUBLIC_IP_ADDRESS, ASSOCIATE_PUBLIC_IP_ADDRESS,
wrapper.getCommonInputs().getDelimiter(), index, false);
- 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 42.
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
if (isNotBlank(wrapper.getCustomInputs().getSubnetId())) {
setSpecificQueryParamValue(queryParamsMap, referenceArray, wrapper.getCustomInputs().getSubnetId(),
PRIVATE_IP_ADDRESSES_STRING, SUBNET_ID_INPUT, SUBNET_ID, wrapper.getCommonInputs().getDelimiter(),
index);
}
- 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 40.
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
if (isNotBlank(wrapper.getNetworkInputs().getNetworkInterfaceDescription())) {
setSpecificQueryParamValue(queryParamsMap, referenceArray,
wrapper.getNetworkInputs().getNetworkInterfaceDescription(),
PRIVATE_IP_ADDRESSES_STRING, NETWORK_INTERFACE_DESCRIPTION, DESCRIPTION,
wrapper.getCommonInputs().getDelimiter(), index);
- 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 40.
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