BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

      test('last list item with a non list item node', async () => {
        const {editor} = testEnv;

        await editor.update(() => {
          const paragraphNode = $createParagraphNode();
resources/js/wysiwyg/lexical/list/__tests__/unit/LexicalListItemNode.test.ts on lines 317..346

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

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('middle list item with a non list item node', async () => {
        const {editor} = testEnv;

        await editor.update(() => {
          const paragraphNode = $createParagraphNode();
resources/js/wysiwyg/lexical/list/__tests__/unit/LexicalListItemNode.test.ts on lines 288..315

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

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

Method formatTextUsingMatchPositions has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function formatTextUsingMatchPositions(array $matchPositions, string $originalText, int $targetLength): string
    {
        $maxEnd = mb_strlen($originalText);
        $fetchAll = ($targetLength === 0);
        $contextLength = ($fetchAll ? 0 : 32);
Severity: Major
Found in app/Search/SearchResultsFormatter.php - About 2 hrs to fix

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

    export function $wrapNodes(
      selection: BaseSelection,
      createElement: () => ElementNode,
      wrappingElement: null | ElementNode = null,
    ): void {
    Severity: Major
    Found in resources/js/wysiwyg/lexical/selection/range-selection.ts - About 2 hrs to fix

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

      export function $unmergeCell(): void {
        const selection = $getSelection();
        invariant(
          $isRangeSelection(selection) || $isTableSelection(selection),
          'Expected a RangeSelection or TableSelection',
      Severity: Major
      Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts - About 2 hrs to fix

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

        export function $insertTableRow__EXPERIMENTAL(insertAfter = true): void {
          const selection = $getSelection();
          invariant(
            $isRangeSelection(selection) || $isTableSelection(selection),
            'Expected a RangeSelection or TableSelection',
        Severity: Major
        Found in resources/js/wysiwyg/lexical/table/LexicalTableUtils.ts - About 2 hrs to fix

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

          export function $convertTableCellNodeElement(
            domNode: Node,
          ): DOMConversionOutput {
            const domNode_ = domNode as HTMLTableCellElement;
            const nodeName = domNode.nodeName.toLowerCase();
          Severity: Major
          Found in resources/js/wysiwyg/lexical/table/LexicalTableCellNode.ts - About 2 hrs to fix

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

                beforeEach(async () => {
                  const {editor} = testEnv;
                  await editor.update(() => {
                    const root = $getRoot();
                    const paragraph = $createParagraphNode();
            resources/js/wysiwyg/lexical/core/__tests__/unit/HTMLCopyAndPaste.test.ts on lines 25..33
            resources/js/wysiwyg/lexical/table/__tests__/unit/LexicalTableNode.test.ts on lines 65..73

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

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

                  beforeEach(async () => {
                    const {editor} = testEnv;
                    await editor.update(() => {
                      const root = $getRoot();
                      const paragraph = $createParagraphNode();
            resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalTabNode.test.ts on lines 38..46
            resources/js/wysiwyg/lexical/table/__tests__/unit/LexicalTableNode.test.ts on lines 65..73

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

            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

                test('AutoLinkNode.getTarget()', async () => {
                  const {editor} = testEnv;
            
                  await editor.update(() => {
                    const autoLinkNode = new AutoLinkNode('https://example.com/foo', {
            resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 170..180
            resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 93..103
            resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 151..161

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

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

                  beforeEach(async () => {
                    const {editor} = testEnv;
                    await editor.update(() => {
                      const root = $getRoot();
                      const paragraph = $createParagraphNode();
            resources/js/wysiwyg/lexical/core/__tests__/unit/HTMLCopyAndPaste.test.ts on lines 25..33
            resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalTabNode.test.ts on lines 38..46

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

            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

                test('LinkNode.getTarget()', 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 112..122
            resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 170..180
            resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 151..161

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

            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

                test('LinkNode.getTitle()', 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 112..122
            resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 170..180
            resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 93..103

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

            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

                test('AutoLinkNode.getTitle()', async () => {
                  const {editor} = testEnv;
            
                  await editor.update(() => {
                    const autoLinkNode = new AutoLinkNode('https://example.com/foo', {
            resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 112..122
            resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 93..103
            resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalLinkNode.test.ts on lines 151..161

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

            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 (minRow < exploredMinRow) {
                    // Expand on top
                    const columnDiff = exploredMaxColumn - exploredMinColumn;
                    const previousRow = exploredMinRow - 1;
                    for (let i = 0; i <= columnDiff; i++) {
            Severity: Major
            Found in resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts and 1 other location - About 2 hrs to fix
            resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts on lines 298..306

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

            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() sanitizes javascript: URLs', async () => {
                  const {editor} = testEnv;
            
                  await editor.update(() => {
                    // eslint-disable-next-line no-script-url
            resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 276..286

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

            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 (
                      focus.key === key &&
                      focus.type === 'text' &&
                      focus.offset > textSize &&
                      focus.offset <= nextTextSize
            Severity: Major
            Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts and 1 other location - About 2 hrs to fix
            resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts on lines 1008..1017

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

            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 (maxRow > exploredMaxRow) {
                    // Expand on the bottom
                    const columnDiff = exploredMaxColumn - exploredMinColumn;
                    const nextRow = exploredMaxRow + 1;
                    for (let i = 0; i <= columnDiff; i++) {
            Severity: Major
            Found in resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts and 1 other location - About 2 hrs to fix
            resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts on lines 280..288

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

            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 (minColumn < exploredMinColumn) {
                    // Expand on the left
                    const rowDiff = exploredMaxRow - exploredMinRow;
                    const previousColumn = exploredMinColumn - 1;
                    for (let i = 0; i <= rowDiff; i++) {
            Severity: Major
            Found in resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts and 1 other location - About 2 hrs to fix
            resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts on lines 289..297

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

            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 (maxColumn > exploredMaxColumn) {
                    // Expand on the right
                    const rowDiff = exploredMaxRow - exploredMinRow;
                    const nextColumn = exploredMaxColumn + 1;
                    for (let i = 0; i <= rowDiff; i++) {
            Severity: Major
            Found in resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts and 1 other location - About 2 hrs to fix
            resources/js/wysiwyg/lexical/table/LexicalTableSelection.ts on lines 271..279

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

            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

            Severity
            Category
            Status
            Source
            Language