src/chat/infinite.js
Function infiniteMessageArea
has a Cognitive Complexity of 181 (exceeds 5 allowed). Consider refactoring. Open
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/')
- 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 infiniteMessageArea
has 584 lines of code (exceeds 25 allowed). Consider refactoring. Open
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/')
File infinite.js
has 645 lines of code (exceeds 250 allowed). Consider refactoring. Open
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
Function newMessageForm
has 163 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function newMessageForm (messageTable) {
var form = dom.createElement('tr')
var lhs = dom.createElement('td')
var middle = dom.createElement('td')
var rhs = dom.createElement('td')
Function renderMessageTable
has 155 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function renderMessageTable (date, live) {
var scrollBackButton
var scrollForwardButton
/// ///////////////// Scroll down adding more above
Function sendMessage
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function sendMessage (text) {
var now = new Date()
await addNewTableIfNewDay(now)
if (!text) {
Function turnOnInput
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function turnOnInput () {
if (options.menuHandler && menuButton) {
const menuOptions = {
me,
dom,
Function loadMoreWhereNeeded
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function loadMoreWhereNeeded (event, fixScroll) {
if (lock) return
lock = true
const freeze = !fixScroll
const magicZone = 150
Function syncMessages
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function syncMessages (about, messageTable) {
var displayed = {}
var ele, ele2
for (ele = messageTable.firstChild; ele; ele = ele.nextSibling) {
if (ele.AJAR_subject) {
Function go
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function go () {
function yank () {
selectedMessageTable.selectedElement.scrollIntoView({ block: 'center' })
}
Function addNewTableIfNewDay
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
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)) {
Function createIfNotExists
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function createIfNotExists (doc, contentType = 'text/turtle', data = '') {
const fetcher = UI.store.fetcher
try {
var response = await fetcher.load(doc)
} catch (err) {
Function insertPreviousMessages
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function createIfNotExists
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
async function createIfNotExists (doc, contentType = 'text/turtle', data = '') {
const fetcher = UI.store.fetcher
try {
var response = await fetcher.load(doc)
} catch (err) {
- 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"