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 function isUnderline(
  key: string,
  altKey: boolean,
  metaKey: boolean,
  ctrlKey: boolean,
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts and 3 other locations - About 1 hr to fix
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 786..795
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 797..806
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 895..904

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 64.

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 function isBold(
  key: string,
  altKey: boolean,
  metaKey: boolean,
  ctrlKey: boolean,
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts and 3 other locations - About 1 hr to fix
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 797..806
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 808..817
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 895..904

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 64.

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 function isItalic(
  key: string,
  altKey: boolean,
  metaKey: boolean,
  ctrlKey: boolean,
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts and 3 other locations - About 1 hr to fix
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 786..795
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 808..817
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 895..904

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 64.

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 function isUndo(
  key: string,
  shiftKey: boolean,
  metaKey: boolean,
  ctrlKey: boolean,
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts and 3 other locations - About 1 hr to fix
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 786..795
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 797..806
resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 808..817

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 64.

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 3 locations. Consider refactoring.
Open

  static importJSON(serializedTabNode: SerializedTabNode): TabNode {
    const node = $createTabNode();
    node.setFormat(serializedTabNode.format);
    node.setStyle(serializedTabNode.style);
    return node;
Severity: Major
Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTabNode.ts and 2 other locations - About 1 hr to fix
resources/js/wysiwyg/lexical/rich-text/index.ts on lines 168..173
resources/js/wysiwyg/nodes/details.ts on lines 91..96

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 64.

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 3 locations. Consider refactoring.
Open

    static importJSON(serializedNode: SerializedDetailsNode): DetailsNode {
        const node = $createDetailsNode();
        node.setId(serializedNode.id);
        node.setDirection(serializedNode.direction);
        return node;
Severity: Major
Found in resources/js/wysiwyg/nodes/details.ts and 2 other locations - About 1 hr to fix
resources/js/wysiwyg/lexical/core/nodes/LexicalTabNode.ts on lines 50..55
resources/js/wysiwyg/lexical/rich-text/index.ts on lines 168..173

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 64.

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 3 locations. Consider refactoring.
Open

  static importJSON(serializedNode: SerializedQuoteNode): QuoteNode {
    const node = $createQuoteNode();
    node.setFormat(serializedNode.format);
    node.setIndent(serializedNode.indent);
    return node;
Severity: Major
Found in resources/js/wysiwyg/lexical/rich-text/index.ts and 2 other locations - About 1 hr to fix
resources/js/wysiwyg/lexical/core/nodes/LexicalTabNode.ts on lines 50..55
resources/js/wysiwyg/nodes/details.ts on lines 91..96

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 64.

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

    assertEditorState(editor.getEditorState(), [
      {
        __key: 'root',
      },
      {
resources/js/wysiwyg/lexical/headless/__tests__/unit/LexicalHeadlessEditor.test.ts on lines 105..122

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 64.

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

    assertEditorState(editor.getEditorState(), [
      {
        __key: 'root',
      },
      {
resources/js/wysiwyg/lexical/headless/__tests__/unit/LexicalHeadlessEditor.test.ts on lines 78..95

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 64.

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 createRectsFromDOMRange has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function createRectsFromDOMRange(
  editor: LexicalEditor,
  range: Range,
): Array<ClientRect> {
  const rootElement = editor.getRootElement();
Severity: Minor
Found in resources/js/wysiwyg/lexical/selection/utils.ts - About 1 hr to fix

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

    export function $getTableCellNodeRect(tableCellNode: TableCellNode): {
      rowIndex: number;
      columnIndex: number;
      rowSpan: number;
      colSpan: number;
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts - About 1 hr to fix

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

      export function $garbageCollectDetachedNodes(
        prevEditorState: EditorState,
        editorState: EditorState,
        dirtyLeaves: Set<NodeKey>,
        dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>,
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalGC.ts - About 1 hr to fix

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

          constructor(
            editorState: EditorState,
            parentEditor: null | LexicalEditor,
            nodes: RegisteredNodes,
            config: EditorConfig,
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts - About 1 hr to fix

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

              protected async request(url: string, options: RequestOptions & RequestInit = {}): Promise<FormattedResponse> {
                  let requestUrl = url;
          
                  if (!requestUrl.startsWith('http')) {
                      requestUrl = window.baseUrl(requestUrl);
          Severity: Minor
          Found in resources/js/services/http.ts - About 1 hr to fix

            Function init has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            export async function init(editor) {
                const Code = await window.importVersioned('code');
            
                /**
                 * @param {ViewUpdate} v
            Severity: Minor
            Found in resources/js/markdown/codemirror.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 getConnection has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function getConnection()
                {
                    if ($this->ldapConnection !== null) {
                        return $this->ldapConnection;
                    }
            Severity: Minor
            Found in app/Access/LdapService.php - 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 formatSingle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function formatSingle(Entity $entity): array
                {
                    $result = [];
                    $values = (clone $entity)->toArray();
            
            
            Severity: Minor
            Found in app/Api/ApiEntityListFormatter.php - 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 parse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function parse(): int
                {
                    $nodesAdded = 0;
                    $tags = $this->locateAndIsolateIncludeTags();
            
            
            Severity: Minor
            Found in app/Entities/Tools/PageIncludeParser.php - 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 ensureDeletable has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function ensureDeletable(Entity $entity): void
                {
                    $customHomeId = intval(explode(':', setting('app-homepage', '0:'))[0]);
                    $customHomeActive = setting('app-homepage-type') === 'page';
                    $removeCustomHome = false;
            Severity: Minor
            Found in app/Entities/Tools/TrashCan.php - 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 wrapContinuousInlines has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            function wrapContinuousInlines(
              domNode: Node,
              nodes: Array<LexicalNode>,
              createWrapperFn: () => ElementNode,
            ): Array<LexicalNode> {
            Severity: Minor
            Found in resources/js/wysiwyg/lexical/html/index.ts - 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

            Severity
            Category
            Status
            Source
            Language