michielbdejong/solid-ui

View on GitHub
src/chat/infinite.js

Summary

Maintainability
F
1 wk
Test Coverage

Function infiniteMessageArea has a Cognitive Complexity of 181 (exceeds 5 allowed). Consider refactoring.
Open

export function infiniteMessageArea (dom, kb, chatChannel, options) {
  kb = kb || UI.store
  const ns = UI.ns
  const WF = $rdf.Namespace('http://www.w3.org/2005/01/wf/flow#')
  const DCT = $rdf.Namespace('http://purl.org/dc/terms/')
Severity: Minor
Found in src/chat/infinite.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 infiniteMessageArea has 584 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function infiniteMessageArea (dom, kb, chatChannel, options) {
  kb = kb || UI.store
  const ns = UI.ns
  const WF = $rdf.Namespace('http://www.w3.org/2005/01/wf/flow#')
  const DCT = $rdf.Namespace('http://purl.org/dc/terms/')
Severity: Major
Found in src/chat/infinite.js - About 2 days to fix

    File infinite.js has 645 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    //  Common code for a discussion are a of messages about something
    //   This version runs over a series of files for different time periods
    //
    //  Parameters for the whole chat like its title are stred on
    //  index.ttl#this and the chats messages are stored in YYYY/MM/DD/chat.ttl
    Severity: Major
    Found in src/chat/infinite.js - About 1 day to fix

      Function newMessageForm has 163 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function newMessageForm (messageTable) {
          var form = dom.createElement('tr')
          var lhs = dom.createElement('td')
          var middle = dom.createElement('td')
          var rhs = dom.createElement('td')
      Severity: Major
      Found in src/chat/infinite.js - About 6 hrs to fix

        Function renderMessageTable has 155 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function renderMessageTable (date, live) {
            var scrollBackButton
            var scrollForwardButton
        
            /// /////////////////   Scroll down adding more above
        Severity: Major
        Found in src/chat/infinite.js - About 6 hrs to fix

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

              async function sendMessage (text) {
                var now = new Date()
                await addNewTableIfNewDay(now)
          
                if (!text) {
          Severity: Major
          Found in src/chat/infinite.js - About 2 hrs to fix

            Function turnOnInput has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function turnOnInput () {
                  if (options.menuHandler && menuButton) {
                    const menuOptions = {
                      me,
                      dom,
            Severity: Major
            Found in src/chat/infinite.js - About 2 hrs to fix

              Function loadMoreWhereNeeded has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async function loadMoreWhereNeeded (event, fixScroll) {
                  if (lock) return
                  lock = true
                  const freeze = !fixScroll
                  const magicZone = 150
              Severity: Minor
              Found in src/chat/infinite.js - About 1 hr to fix

                Function syncMessages has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function syncMessages (about, messageTable) {
                    var displayed = {}
                    var ele, ele2
                    for (ele = messageTable.firstChild; ele; ele = ele.nextSibling) {
                      if (ele.AJAR_subject) {
                Severity: Minor
                Found in src/chat/infinite.js - About 1 hr to fix

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

                    async function go () {
                      function yank () {
                        selectedMessageTable.selectedElement.scrollIntoView({ block: 'center' })
                      }
                  
                  
                  Severity: Minor
                  Found in src/chat/infinite.js - About 1 hr to fix

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

                      async function addNewTableIfNewDay (now) {
                        // let now = new Date()
                        // @@ Remove listener from previous table as it is now static
                        const newChatDocument = dateFolder.leafDocumentFromDate(now)
                        if (!newChatDocument.sameTerm(latest.messageTable.chatDocument)) {
                    Severity: Minor
                    Found in src/chat/infinite.js - About 1 hr to fix

                      Function createIfNotExists has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      async function createIfNotExists (doc, contentType = 'text/turtle', data = '') {
                        const fetcher = UI.store.fetcher
                        try {
                          var response = await fetcher.load(doc)
                        } catch (err) {
                      Severity: Minor
                      Found in src/chat/infinite.js - About 1 hr to fix

                        Function insertPreviousMessages has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async function insertPreviousMessages (backwards) {
                            const extremity = backwards ? earliest : latest
                            let date = extremity.messageTable.date // day in mssecs
                        
                            date = await dateFolder.loadPrevious(date, backwards) // backwards
                        Severity: Minor
                        Found in src/chat/infinite.js - About 1 hr to fix

                          Function createIfNotExists has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          async function createIfNotExists (doc, contentType = 'text/turtle', data = '') {
                            const fetcher = UI.store.fetcher
                            try {
                              var response = await fetcher.load(doc)
                            } catch (err) {
                          Severity: Minor
                          Found in src/chat/infinite.js - About 35 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