BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

Similar blocks of code found in 4 locations. Consider refactoring.
Open

export const pasteColumnAfter: EditorButtonDefinition = {
    label: 'Paste column after',
    format: 'long',
    action(context: EditorUiContext) {
        context.editor.update(() => {
Severity: Major
Found in resources/js/wysiwyg/ui/defaults/buttons/tables.ts and 3 other locations - About 4 hrs to fix
resources/js/wysiwyg/ui/defaults/buttons/tables.ts on lines 213..227
resources/js/wysiwyg/ui/defaults/buttons/tables.ts on lines 229..243
resources/js/wysiwyg/ui/defaults/buttons/tables.ts on lines 277..291

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 126.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

export const pasteRowBefore: EditorButtonDefinition = {
    label: 'Paste row before',
    format: 'long',
    action(context: EditorUiContext) {
        context.editor.update(() => {
Severity: Major
Found in resources/js/wysiwyg/ui/defaults/buttons/tables.ts and 3 other locations - About 4 hrs to fix
resources/js/wysiwyg/ui/defaults/buttons/tables.ts on lines 229..243
resources/js/wysiwyg/ui/defaults/buttons/tables.ts on lines 277..291
resources/js/wysiwyg/ui/defaults/buttons/tables.ts on lines 293..307

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 126.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  if ($isElementNode(anchorNode)) {
    const childSize = anchorNode.getChildrenSize();
    const anchorOffsetAtEnd = anchorOffset >= childSize;
    const child = anchorOffsetAtEnd
      ? anchorNode.getChildAtIndex(childSize - 1)
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 4 hrs to fix
resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 2446..2459

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 125.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  if ($isElementNode(focusNode)) {
    const childSize = focusNode.getChildrenSize();
    const focusOffsetAtEnd = focusOffset >= childSize;
    const child = focusOffsetAtEnd
      ? focusNode.getChildAtIndex(childSize - 1)
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts and 1 other location - About 4 hrs to fix
resources/js/wysiwyg/lexical/core/LexicalSelection.ts on lines 2432..2445

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 125.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function onSelectionChange has 112 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function onSelectionChange(
  domSelection: Selection,
  editor: LexicalEditor,
  isActive: boolean,
): void {
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 4 hrs to fix

    Function modify has 111 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      Selection.prototype.modify = function (alter, direction, granularity) {
        // This is not a thorough implementation, it was more to get tests working
        // given the refactor to use this selection method.
        const symbol = Object.getOwnPropertySymbols(this)[0];
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
    Severity: Major
    Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts - About 4 hrs to fix

      Function $convertTableCellNodeElement has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      export function $convertTableCellNodeElement(
          domNode: Node,
      ): DOMConversionOutput {
          const domNode_ = domNode as HTMLTableCellElement;
          const nodeName = domNode.nodeName.toLowerCase();
      Severity: Minor
      Found in resources/js/wysiwyg/nodes/custom-table-cell.ts - About 4 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 $convertTableCellNodeElement has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      export function $convertTableCellNodeElement(
        domNode: Node,
      ): DOMConversionOutput {
        const domNode_ = domNode as HTMLTableCellElement;
        const nodeName = domNode.nodeName.toLowerCase();
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/table/LexicalTableCellNode.ts - About 4 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 modify has 110 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        modify(
          alter: 'move' | 'extend',
          isBackward: boolean,
          granularity: 'character' | 'word' | 'lineboundary',
        ): void {
      Severity: Major
      Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 4 hrs to fix

        Function splice has 110 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          splice(
            start: number,
            deleteCount: number,
            nodesToInsert: Array<LexicalNode>,
          ): this {
        Severity: Major
        Found in resources/js/wysiwyg/lexical/core/nodes/LexicalElementNode.ts - About 4 hrs to fix

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          export function $getAncestor<NodeType extends LexicalNode = LexicalNode>(
            node: LexicalNode,
            predicate: (ancestor: LexicalNode) => ancestor is NodeType,
          ) {
            let parent = node;
          Severity: Major
          Found in resources/js/wysiwyg/lexical/selection/range-selection.ts and 1 other location - About 4 hrs to fix
          resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 1698..1707

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 123.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          export function $getAncestor<NodeType extends LexicalNode = LexicalNode>(
            node: LexicalNode,
            predicate: (ancestor: LexicalNode) => ancestor is NodeType,
          ) {
            let parent = node;
          Severity: Major
          Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts and 1 other location - About 4 hrs to fix
          resources/js/wysiwyg/lexical/selection/range-selection.ts on lines 599..608

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 123.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              test('LinkNode.setRel()', async () => {
                const {editor} = testEnv;
          
                await editor.update(() => {
                  const linkNode = new LinkNode('https://example.com/foo', {
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 153..168

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 122.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              test('AutoLinkNode.setRel()', async () => {
                const {editor} = testEnv;
          
                await editor.update(() => {
                  const autoLinkNode = new AutoLinkNode('https://example.com/foo', {
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 134..149

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 122.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              test('AutoLinkNode.createDOM()', async () => {
                const {editor} = testEnv;
          
                await editor.update(() => {
                  const autoLinkNode = new AutoLinkNode('https://example.com/foo');
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 179..195

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 121.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              test('LinkNode.createDOM()', async () => {
                const {editor} = testEnv;
          
                await editor.update(() => {
                  const linkNode = new LinkNode('https://example.com/foo');
          resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 220..236

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 121.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function registerNestedElementResolver has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

          export function registerNestedElementResolver<N extends ElementNode>(
            editor: LexicalEditor,
            targetNode: Klass<N>,
            cloneNode: (from: N) => N,
            handleOverlap: (from: N, to: N) => void,
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/utils/index.ts - About 4 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 $unmergeCell has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

          export function $unmergeCell(): void {
            const selection = $getSelection();
            invariant(
              $isRangeSelection(selection) || $isTableSelection(selection),
              'Expected a RangeSelection or TableSelection',
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts - About 4 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 $createNode has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

          function $createNode(
            key: NodeKey,
            parentDOM: null | HTMLElement,
            insertDOM: null | Node,
          ): HTMLElement {
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/core/LexicalReconciler.ts - About 4 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 $patchStyleText has 106 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function $patchStyleText(
            selection: BaseSelection,
            patch: Record<
              string,
              | string
          Severity: Major
          Found in resources/js/wysiwyg/lexical/selection/lexical-node.ts - About 4 hrs to fix
            Severity
            Category
            Status
            Source
            Language