ucberkeley/moocchat

View on GitHub
app/assets/javascripts/web_socket.js

Summary

Maintainability
C
1 day
Test Coverage

Function showWelcomeMessage has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  showWelcomeMessage: function(){
    if (this.group.length == 1) {
      this.showMessage("No one is currently available to chat with you. You may use this chatroom to reflect on the question. Click the end button above when done.", "system");
    } else if (this.group.length == 2) {
      var you_learner = '';
Severity: Minor
Found in app/assets/javascripts/web_socket.js - About 2 hrs 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

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

    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

      Function showWelcomeMessage has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        showWelcomeMessage: function(){
          if (this.group.length == 1) {
            this.showMessage("No one is currently available to chat with you. You may use this chatroom to reflect on the question. Click the end button above when done.", "system");
          } else if (this.group.length == 2) {
            var you_learner = '';
      Severity: Minor
      Found in app/assets/javascripts/web_socket.js - About 1 hr to fix

        Function initialize has a Cognitive Complexity of 10 (exceeds 5 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

        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

        Function receiveMessages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          receiveMessages: function() {
            var self = this;
            this.ws.onmessage = function(message) {
              var data = JSON.parse(message.data)
              if (data.type == "message" & self.isBoth()) {
        Severity: Minor
        Found in app/assets/javascripts/web_socket.js - About 55 mins 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

        Avoid deeply nested control flow statements.
        Open

                      if (learners == '') {
                        learners = i + 1;
                      } else {
                        learners = learners + " and " + (i + 1);
                      }
        Severity: Major
        Found in app/assets/javascripts/web_socket.js - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status