Method findMostFrequent
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static String findMostFrequent(List<String> answers, int[] numMostFreqVotes, int numAssignments) throws UnresolvedAnswerException {
if(answers == null || answers.size() == 0){
throw new UnresolvedAnswerException("No answers submitted", ErrorReason.InProgress);
}
- 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 findMostFrequent
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static String findMostFrequent(List<String> answers, int[] numMostFreqVotes, int numAssignments) throws UnresolvedAnswerException {
if(answers == null || answers.size() == 0){
throw new UnresolvedAnswerException("No answers submitted", ErrorReason.InProgress);
}
Method summarizeResults
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static Map<String, List<String>> summarizeResults(
Map<String, List<String[]>> hitAssignments, int answerIndex, int numAssignmentsIndex) {
Map<String, List<String>> hitSummaries = new LinkedHashMap<String, List<String>>();
for(Map.Entry<String,List<String[]>> hitResults : hitAssignments.entrySet()){
- 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 summarizeResults
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Map<String, List<String>> summarizeResults(
Map<String, List<String[]>> hitAssignments, int answerIndex, int numAssignmentsIndex) {
Map<String, List<String>> hitSummaries = new LinkedHashMap<String, List<String>>();
for(Map.Entry<String,List<String[]>> hitResults : hitAssignments.entrySet()){
Method parseHitAssignments
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static Map<String, List<String[]>> parseHitAssignments(
String resultsFile, String[] requiredFields, int[] fieldIndicesPlaceholder, char fieldSeparator) {
Map<String, List<String[]>> hitAssignments = new LinkedHashMap<String, List<String[]>>();
try {
Method parseHitAssignments
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static Map<String, List<String[]>> parseHitAssignments(
String resultsFile, String[] requiredFields, int[] fieldIndicesPlaceholder, char fieldSeparator) {
Map<String, List<String[]>> hitAssignments = new LinkedHashMap<String, List<String[]>>();
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
Method extractQuestion
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static Map<String, String> extractQuestion(Map<String, List<String[]>> hitAssignments, int questionIndex) {
Map<String, String> hitQuestions = new LinkedHashMap<String, String>();
for(Map.Entry<String, List<String[]>> hitResults : hitAssignments.entrySet()){
String hitId = hitResults.getKey();
List<String[]> assignmentsDetails = hitResults.getValue();
- 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"