Idrinth/IDotD

View on GitHub
src/mods/chat.js

Summary

Maintainability
F
2 wks
Test Coverage

File chat.js has 1223 lines of code (exceeds 250 allowed). Consider refactoring.
Open

idrinth.chat = {
  /**
     * own user id
     * @type Number
     */
Severity: Major
Found in src/mods/chat.js - About 3 days to fix

Function refreshChats has a Cognitive Complexity of 155 (exceeds 5 allowed). Consider refactoring.
Open

  refreshChats: function() {
    /**
         * 
         * @param {String} data
         * @returns {undefined}
Severity: Minor
Found in src/mods/chat.js - About 3 days 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 refreshChats has 314 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  refreshChats: function() {
    /**
         * 
         * @param {String} data
         * @returns {undefined}
Severity: Major
Found in src/mods/chat.js - About 1 day to fix

Function start has 288 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  start: function() {
    /**
         * 
         * @returns {HTMLElement}
         */
Severity: Major
Found in src/mods/chat.js - About 1 day to fix

Function build has 240 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    let build = function() {
      /**
             * 
             * @param {String} label
             * @returns {Object}
Severity: Major
Found in src/mods/chat.js - About 1 day to fix

Function applyMessages has 226 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    let applyMessages = function(data) {
      /**
             * 
             * @param {String} messages
             * @returns {undefined}
Severity: Major
Found in src/mods/chat.js - About 1 day to fix

Function processMessages has 209 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      let processMessages = function(messages) {
        /**
                 * 
                 * @param {Array} chatMessages
                 * @param {Number} chatId
Severity: Major
Found in src/mods/chat.js - About 1 day to fix

Function addMessages has 159 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        let addMessages = function(chatMessages, chatId, chatElement) {
          /**
                     * 
                     * @param {String} message
                     * @param {HTMLElement} chat
Severity: Major
Found in src/mods/chat.js - About 6 hrs to fix

Function buildMessage has 136 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          let buildMessage = function(message, chat, chatId, messageId) {
            /**
                         * 
                         * @returns {String}
                         */
Severity: Major
Found in src/mods/chat.js - About 5 hrs to fix

Function userclick has 121 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  userclick: function(element, user, chat) {
    if (
      !idrinth.chat.chatRank[chat][idrinth.chat.self] ||
      parseInt(user, 10) === parseInt(idrinth.chat.self, 10)
    ) {
Severity: Major
Found in src/mods/chat.js - About 4 hrs to fix

Function userclick has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  userclick: function(element, user, chat) {
    if (
      !idrinth.chat.chatRank[chat][idrinth.chat.self] ||
      parseInt(user, 10) === parseInt(idrinth.chat.self, 10)
    ) {
Severity: Minor
Found in src/mods/chat.js - About 3 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 replaceInText has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  replaceInText: function(message, regex, callbacks, lastField) {
    /**
         * 
         * @param {String} message
         * @param {RegExp} regex
Severity: Minor
Found in src/mods/chat.js - About 3 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 getPopupContent has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    let getPopupContent = function(chat, user, rankId) {
      /**
             * 
             * @param {Number} chat
             * @returns {Array}
Severity: Major
Found in src/mods/chat.js - About 3 hrs to fix

Function refreshMembers has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    let refreshMembers = function() {
      /**
             * 
             * @param {String} data
             * @returns {undefined}
Severity: Major
Found in src/mods/chat.js - About 2 hrs to fix

Function replaceInText has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  replaceInText: function(message, regex, callbacks, lastField) {
    /**
         * 
         * @param {String} message
         * @param {RegExp} regex
Severity: Major
Found in src/mods/chat.js - About 2 hrs to fix

Function applyMembers has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      let applyMembers = function(data) {
        /**
                 * 
                 * @returns {undefined}
                 */
Severity: Major
Found in src/mods/chat.js - About 2 hrs to fix

Function showOptions has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  showOptions: function(event, element) {
    event.preventDefault();
    idrinth.ui.base.appendChild(
      idrinth.ui.buildElement({
        type: "ul",
Severity: Major
Found in src/mods/chat.js - About 2 hrs to fix

chat has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

idrinth.chat = {
  /**
     * own user id
     * @type Number
     */
Severity: Minor
Found in src/mods/chat.js - About 2 hrs to fix

Function notify has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            let notify = function(message, own, chatId) {
              /**
                             * 
                             * @param {Number} chatId
                             * @returns {Boolean}
Severity: Major
Found in src/mods/chat.js - About 2 hrs to fix

Function applyMemberData has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        let applyMemberData = function() {
          /**
                     * 
                     * @param {HTMLElement} chat
                     * @param {Number} chatId
Severity: Minor
Found in src/mods/chat.js - About 2 hrs to fix

Function getPromotionOptions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      let getPromotionOptions = function(chat) {
        let promotionModes = [
          {
            chat: chat,
            label: "chat.actions.banUser",
Severity: Minor
Found in src/mods/chat.js - About 1 hr to fix

Function buildEmoticons has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  buildEmoticons: function(message) {
    if (!idrinth.chat.emotes.lookup) {
      return message;
    }
    let part = idrinth.core.escapeRegExp(
Severity: Minor
Found in src/mods/chat.js - About 1 hr to fix

Function start has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  start: function() {
    /**
         * 
         * @returns {HTMLElement}
         */
Severity: Minor
Found in src/mods/chat.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 complexHandler has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    let complexHandler = function(message, regex, callbacks, lastField) {
      /**
             * 
             * @param {Number} count
             * @param {Array} callbacks
Severity: Minor
Found in src/mods/chat.js - About 1 hr to fix

Function loginActions has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  loginActions: function(key) {
    let chatLogin,
      success,
      urls = {
        register: "chat-service/register/",
Severity: Minor
Found in src/mods/chat.js - About 1 hr to fix

Function joinCallback has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  joinCallback: function(reply) {
    if (!reply) {
      idrinth.core.alert(idrinth.text.get("chat.error.join"));
      return;
    }
Severity: Minor
Found in src/mods/chat.js - About 1 hr to fix

Function addMemberElement has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          let addMemberElement = function(chat, chatId, userId) {
            let usedPlatforms = "";
            for (var pkey in idrinth.chat.users[userId].platforms) {
              if (idrinth.chat.users[userId].platforms[pkey]) {
                usedPlatforms += pkey;
Severity: Minor
Found in src/mods/chat.js - About 1 hr to fix

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

  loginCallback: function(data) {
    if (!data) {
      idrinth.core.alert(idrinth.text.get("chat.error.login"));
      return;
    }
Severity: Minor
Found in src/mods/chat.js - About 1 hr to fix

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

        let setChatClass = function(isNew, chat, chatId) {
          /**
                     * 
                     * @param {HTMLElement} element
                     * @returns {Boolean}
Severity: Minor
Found in src/mods/chat.js - About 1 hr to fix

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

  buildMessageText: function(message) {
    let reg = new RegExp("(^|\\W)(https?://([^/ ]+)(/.*?)?)($| )", "ig");
    return idrinth.chat.replaceInText(
      message,
      reg,
Severity: Minor
Found in src/mods/chat.js - About 1 hr to fix

Function openCloseChat has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  openCloseChat: function(element) {
    let chat = element.parentNode;
    if (
      chat.getAttribute("class") === "idrinth-hovering-box active" ||
      chat.getAttribute("class") === "idrinth-hovering-box active left-sided"
Severity: Minor
Found in src/mods/chat.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 partHandler has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      let partHandler = function(count, callbacks, text, textcontent) {
        /**
                 * 
                 * @param {Array} textcontent
                 * @param {Function} func
Severity: Minor
Found in src/mods/chat.js - About 1 hr to fix

Avoid too many return statements within this function.
Open

      return;
Severity: Major
Found in src/mods/chat.js - About 30 mins to fix

Function joinCallback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  joinCallback: function(reply) {
    if (!reply) {
      idrinth.core.alert(idrinth.text.get("chat.error.join"));
      return;
    }
Severity: Minor
Found in src/mods/chat.js - About 25 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

Function loginCallback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  loginCallback: function(data) {
    if (!data) {
      idrinth.core.alert(idrinth.text.get("chat.error.login"));
      return;
    }
Severity: Minor
Found in src/mods/chat.js - About 25 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

There are no issues that match your filters.

Category
Status