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 = '';
- 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
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{
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();
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 = '';
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{
- 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
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()) {
- 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
Avoid deeply nested control flow statements. Open
if (learners == '') {
learners = i + 1;
} else {
learners = learners + " and " + (i + 1);
}