Showing 132 of 132 total issues
Method updateQualificationType
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public void updateQualificationType( String qualTypeId, String statusString,
String questionFile, String answerFile,
String propertiesFile ) throws Exception
{
String test = 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 runCommand
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected void runCommand(CommandLine cmdLine) throws Exception {
if (!cmdLine.hasOption(QUAL_TYPE) &&
!cmdLine.hasOption(INPUT_FILE)) {
log.error("Either -" + QUAL_TYPE + " or -" + INPUT_FILE + " should be passed");
- 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 sendMessage
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private Reply sendMessage(Message m) {
Reply ret = null;
while (ret == null) {
try {
ret = passMessage(m);
- 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 reviewAssignments
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void reviewAssignments(String fileName) throws IOException {
if (fileName == null) {
throw new IllegalArgumentException("File name is null.");
}
Method runCommand
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void runCommand(CommandLine cmdLine) throws Exception {
if (!cmdLine.hasOption(ARG_TEMPLATE)) {
log.error("Missing: -" + ARG_TEMPLATE);
printHelp();
Method runCommand
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void runCommand(CommandLine cmdLine) throws Exception {
if (!cmdLine.hasOption(ARG_INPUT)) {
log.error("Missing: -" + ARG_INPUT
+ " [path to input file -- ie. c:\\mturk\\helloworld.input]");
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 runCommand
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected void runCommand(CommandLine cmdLine) throws Exception {
if (!cmdLine.hasOption(ARG_INPUT)) {
log.error("Missing: -" + ARG_INPUT
+ " [path to input file -- ie. c:\\mturk\\helloworld.input]");
- 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 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 makeTemplate
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void makeTemplate(String template, String target, String type, String os,
String templateRootDirPath, String targetRootDirPath, String scriptTemplateDir) throws Exception {
String targetDirPath = targetRootDirPath + File.separator + target;
File targetDir = new File(targetDirPath);
Function initialize
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
initialize: function(chatGroup,taskid,rails_mode, type) {
this.type = type;
if(typeof chatGroup == "number"){
this.group = [chatGroup];
} else{
Method update
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def update
@condition = Condition.find(params[:id])
params[:condition][:primary_activity_schema] = (params[:condition][:primary_activity_schema] == "")? nil : ActivitySchema.find(params[:condition][:primary_activity_schema].to_i)
params[:condition][:time_filler] = (params[:condition][:time_filler] == "")? nil : ActivitySchema.find(params[:condition][:time_filler].to_i)
- 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 sessions_show
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def sessions_show
eventlog_sessions = eventlog_sessions(EventLog.where(created_at: parse_datetime_picker_date(params[:datetime_start])..parse_datetime_picker_date(params[:datetime_end])))
@sessions = []
eventlog_sessions.each do |session_events|
- 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 create
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create
params[:condition][:primary_activity_schema] = (params[:condition][:primary_activity_schema] == "")? nil : ActivitySchema.find(params[:condition][:primary_activity_schema].to_i)
params[:condition][:time_filler] = (params[:condition][:time_filler] == "")? nil : ActivitySchema.find(params[:condition][:time_filler].to_i)
#to handle the collection_select to object array
- 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 runCommand
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected void runCommand(CommandLine cmdLine) throws Exception {
if (!cmdLine.hasOption(ARG_QUALTYPE) &&
!cmdLine.hasOption(ARG_INPUT_FILE)) {
log.error("Either -" + ARG_QUALTYPE + " or -" + ARG_INPUT_FILE + " must be passed");
System.exit(-1);
- 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 current_page
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def current_page(condition=nil)
return nil if @where == :finished
@condition ||= condition
array = array_for_current_subsequence
# boundary condition: zero body iterations => skip to epilogue
- 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 getFieldValuesFromFile
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected String[] getFieldValuesFromFile(String fileName, String fieldName) throws IOException {
HITDataCSVReader csvReader = new HITDataCSVReader(fileName);
// check that we have a header
Method processAnswers
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void processAnswers(Map<String, String> values) {
String answers = values.get(ORIG_ANSWER_FIELD);
if (answers == null || HITResults.NO_ANSWER.equals(answers)) {
return ; // return if no answers
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected void initOptions() {
opt.addOption(ARG_TEMPLATE, true,
"(required) The name of one of the sample directories (eg. helloworld).");
opt.addOption(ARG_TARGET, true,
"(required) The name of the target directory (eg. new_application)");
- 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 87.
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