BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

  registerTextContentListener(listener: TextContentListener): () => void {
    const listenerSetOrMap = this._listeners.textcontent;
    listenerSetOrMap.add(listener);
    return () => {
      listenerSetOrMap.delete(listener);
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts and 2 other locations - About 1 hr to fix
resources/js/wysiwyg/lexical/core/LexicalEditor.ts on lines 702..708
resources/js/wysiwyg/lexical/core/LexicalEditor.ts on lines 716..722

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

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

  registerUpdateListener(listener: UpdateListener): () => void {
    const listenerSetOrMap = this._listeners.update;
    listenerSetOrMap.add(listener);
    return () => {
      listenerSetOrMap.delete(listener);
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalEditor.ts and 2 other locations - About 1 hr to fix
resources/js/wysiwyg/lexical/core/LexicalEditor.ts on lines 716..722
resources/js/wysiwyg/lexical/core/LexicalEditor.ts on lines 749..755

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

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('$isListItemNode()', async () => {
      const {editor} = testEnv;

      await editor.update(() => {
        const listItemNode = new ListItemNode();
resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalParagraphNode.test.ts on lines 143..151

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

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('$isParagraphNode()', async () => {
      const {editor} = testEnv;

      await editor.update(() => {
        const paragraphNode = new ParagraphNode();
resources/js/wysiwyg/lexical/list/__tests__/unit/LexicalListItemNode.test.ts on lines 1259..1267

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

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

    public function handle(Connection $db): int
    {
        $oldUrl = str_replace("'", '', $this->argument('oldUrl'));
        $newUrl = str_replace("'", '', $this->argument('newUrl'));

Severity: Minor
Found in app/Console/Commands/UpdateUrlCommand.php - About 1 hr to fix

    Function removeFromParent has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function removeFromParent(node: LexicalNode): void {
      const oldParent = node.getParent();
      if (oldParent !== null) {
        const writableNode = node.getWritable();
        const writableParent = oldParent.getWritable();
    Severity: Minor
    Found in resources/js/wysiwyg/lexical/yjs/Utils.ts - About 1 hr to fix

      Function removeFromParent has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function removeFromParent(node: LexicalNode): void {
        const oldParent = node.getParent();
        if (oldParent !== null) {
          const writableNode = node.getWritable();
          const writableParent = oldParent.getWritable();
      Severity: Minor
      Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts - About 1 hr to fix

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

                await editor.update(() => {
                  barTextNode = new TextNode('bar');
                  barTextNode.toggleUnmergeable();
                  bazTextNode = new TextNode('baz');
                  bazTextNode.toggleUnmergeable();
        resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNode.test.ts on lines 688..694
        resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNode.test.ts on lines 822..828

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

        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

            down: {
                active(elem, parent) {
                    return !(elem.nextElementSibling === null && !parent);
                },
                run(elem, parent) {
        Severity: Major
        Found in resources/js/components/book-sort.js and 1 other location - About 1 hr to fix
        resources/js/components/book-sort.js on lines 47..55

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

        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

            up: {
                active(elem, parent) {
                    return !(elem.previousElementSibling === null && !parent);
                },
                run(elem, parent) {
        Severity: Major
        Found in resources/js/components/book-sort.js and 1 other location - About 1 hr to fix
        resources/js/components/book-sort.js on lines 56..64

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

        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

                await editor.update(() => {
                  barTextNode = new TextNode('bar');
                  barTextNode.toggleUnmergeable();
                  bazTextNode = new TextNode('baz');
                  bazTextNode.toggleUnmergeable();
        resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNode.test.ts on lines 688..694
        resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNode.test.ts on lines 748..754

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

        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

                await editor.update(() => {
                  barTextNode = new TextNode('bar');
                  barTextNode.toggleUnmergeable();
                  bazTextNode = new TextNode('baz');
                  bazTextNode.toggleUnmergeable();
        resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNode.test.ts on lines 748..754
        resources/js/wysiwyg/lexical/core/__tests__/unit/LexicalNode.test.ts on lines 822..828

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

        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

              await editor.update(() => {
                const quoteNode = $createQuoteNode();
                expect(quoteNode.getType()).toBe('quote');
                expect(quoteNode.getTextContent()).toBe('');
              });
        resources/js/wysiwyg/lexical/core/nodes/__tests__/unit/LexicalLineBreakNode.test.ts on lines 18..23

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

        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 (child.__parent === parentKey) {
              if ($isElementNode(child)) {
                $garbageCollectDetachedDeepChildNodes(
                  child,
                  childKey,
        Severity: Major
        Found in resources/js/wysiwyg/lexical/core/LexicalGC.ts and 1 other location - About 1 hr to fix
        resources/js/wysiwyg/lexical/core/LexicalGC.ts on lines 92..109

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

        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 (!node.isAttached()) {
                if ($isElementNode(node)) {
                  $garbageCollectDetachedDeepChildNodes(
                    node,
                    nodeKey,
        Severity: Major
        Found in resources/js/wysiwyg/lexical/core/LexicalGC.ts and 1 other location - About 1 hr to fix
        resources/js/wysiwyg/lexical/core/LexicalGC.ts on lines 53..71

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

        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

              await editor.update(() => {
                const lineBreakNode = $createLineBreakNode();
        
                expect(lineBreakNode.getType()).toEqual('linebreak');
                expect(lineBreakNode.getTextContent()).toEqual('\n');
        resources/js/wysiwyg/lexical/rich-text/__tests__/unit/LexicalQuoteNode.test.ts on lines 24..28

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

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

            public function index(Request $request)
            {
                $this->checkPermission('settings-manage');
                $this->checkPermission('users-manage');
        
        
        Severity: Minor
        Found in app/Activity/Controllers/AuditLogController.php - About 1 hr to fix

          Function registerNestedElementResolver has 46 lines of code (exceeds 25 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 1 hr to fix

            Function moveNativeSelectionForward has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function moveNativeSelectionForward() {
              const domSelection = window.getSelection()!;
              const anchorNode = domSelection.anchorNode!;
              const anchorOffset = domSelection.anchorOffset!;
            
            
            Severity: Minor
            Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts - About 1 hr to fix

              Function importDOM has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                static importDOM(): DOMConversionMap | null {
                  return {
                    '#text': () => ({
                      conversion: $convertTextDOMNode,
                      priority: 0,
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language