ucberkeley/moocchat

View on GitHub

Showing 95 of 132 total issues

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);
        }

Severity: Minor
Found in turk/src/com/amazonaws/mturk/cmd/summary/SummaryUtils.java - About 1 hr to fix

    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]");
    Severity: Minor
    Found in turk/src/com/amazonaws/mturk/cmd/LoadHITs.java - About 1 hr to fix

    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()){
    Severity: Minor
    Found in turk/src/com/amazonaws/mturk/cmd/summary/SummaryUtils.java - About 1 hr to fix

    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);
    Severity: Minor
    Found in turk/src/com/amazonaws/mturk/cmd/MakeTemplate.java - About 1 hr to fix

      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{
      Severity: Minor
      Found in app/assets/javascripts/web_socket.js - About 1 hr to fix

        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)
        Severity: Minor
        Found in app/controllers/conditions_controller.rb - About 1 hr to fix

        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|
        Severity: Minor
        Found in app/controllers/reports_controller.rb - About 1 hr to fix

        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
        Severity: Minor
        Found in app/controllers/conditions_controller.rb - About 1 hr to fix

        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);
        Severity: Minor
        Found in turk/src/com/amazonaws/mturk/cmd/AssignQualification.java - About 1 hr to fix

        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
        Severity: Minor
        Found in app/models/task/task_sequencer.rb - About 1 hr to fix

        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()){
        Severity: Minor
        Found in turk/src/com/amazonaws/mturk/cmd/summary/SummaryUtils.java - About 1 hr to fix

          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 
          Severity: Minor
          Found in turk/src/com/amazonaws/mturk/cmd/AbstractCmd.java - About 1 hr to fix

            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
            Severity: Minor
            Found in turk/src/com/amazonaws/mturk/util/HITResultProcessor.java - About 1 hr to fix

              Method runCommand has 32 lines of code (exceeds 25 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);
              Severity: Minor
              Found in turk/src/com/amazonaws/mturk/cmd/AssignQualification.java - About 1 hr to fix

                Method runCommand has 32 lines of code (exceeds 25 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 + " should be passed");
                Severity: Minor
                Found in turk/src/com/amazonaws/mturk/cmd/UpdateQualificationType.java - About 1 hr to fix

                  Method getHits has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private String[] getHits() {
                      HIT[] hits = null;
                      List<String> ret = new ArrayList<String>();
                      SearchHITsResult result = null;    
                      String[] responseGroup = new String [] { "Minimal", "HITDetail" };
                  Severity: Minor
                  Found in turk/src/com/amazonaws/mturk/cmd/ResetAccount.java - About 1 hr to fix

                  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 getSummary has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public Map<String, List<String>> getSummary(String resultsFile) throws ParseException {
                  
                          // hitid is always required.
                          String[] requiredFields = new String[]{
                                  "annotation", "Answer.inappropriate", "assignments"

                    Method rewriteHeaders has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      private void rewriteHeaders(String source, String destination) throws IOException {
                          BufferedReader reader = null;
                          Writer writer = null;
                          String newline = System.getProperty("line.separator");
                          
                    Severity: Minor
                    Found in turk/src/com/amazonaws/mturk/util/HITResultProcessor.java - About 1 hr to fix

                      Function update has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function update() {
                          $.ajax({
                              url:'https://moocchat.herokuapp.com/get_current_timestamp_utc/',
                              dataType: 'jsonp',
                              type: 'GET',
                      Severity: Minor
                      Found in public/moocchat_global_notification.js - About 1 hr to fix

                        Function sendMessages has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          sendMessages: function() {
                            var self = this;
                            if(this.isBoth()){
                              this.sendChatMessageButton.click(function(event) {
                                event.preventDefault();
                        Severity: Minor
                        Found in app/assets/javascripts/web_socket.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language