BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

Function setTextThemeClassNames has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function setTextThemeClassNames(
  tag: string,
  prevFormat: number,
  nextFormat: number,
  dom: HTMLElement,
Severity: Major
Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 2 hrs to fix

    File TrashCan.php has 251 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace BookStack\Entities\Tools;
    
    use BookStack\Entities\EntityProvider;
    Severity: Minor
    Found in app/Entities/Tools/TrashCan.php - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

              if ($model instanceof Page) {
                  $parentPermission = ($currentParent instanceof Chapter) ? 'chapter-update' : 'book-update';
                  $hasCurrentParentPermission = userCan($parentPermission, $currentParent);
      
                  // This needs to check if there was an intended chapter location in the original sort map
      Severity: Critical
      Found in app/Entities/Tools/BookContents.php - About 2 hrs to fix

        Function deleteTextHandler has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const deleteTextHandler = (command: LexicalCommand<boolean>) => () => {
            const selection = $getSelection();
        
            if (!$isSelectionInTable(selection, tableNode)) {
              return false;
        Severity: Minor
        Found in resources/js/wysiwyg/lexical/table/LexicalTableSelectionHelpers.ts - About 2 hrs to fix

          Function onDocumentSelectionChange has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function onDocumentSelectionChange(event: Event): void {
            const target = event.target as null | Element | Document;
            const targetWindow =
              target == null
                ? null
          Severity: Minor
          Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 2 hrs to fix

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

              static importDOM(): DOMConversionMap | null {
                return {
                  h1: (node: Node) => ({
                    conversion: $convertHeadingElement,
                    priority: 0,
            Severity: Minor
            Found in resources/js/wysiwyg/lexical/rich-text/index.ts - About 2 hrs to fix

              Function updateDOMBlockCursorElement has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function updateDOMBlockCursorElement(
                editor: LexicalEditor,
                rootElement: HTMLElement,
                nextSelection: null | BaseSelection,
              ): void {
              Severity: Minor
              Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts - About 2 hrs to fix

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

                        const config = buildForInput({
                            language: this.wysiwygLanguage,
                            containerElement: this.input,
                            darkMode: document.documentElement.classList.contains('dark-mode'),
                            textDirection: this.wysiwygTextDirection,
                Severity: Major
                Found in resources/js/components/page-comment.js and 1 other location - About 2 hrs to fix
                resources/js/components/page-comments.js on lines 133..140

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

                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

                        const config = buildForInput({
                            language: this.wysiwygLanguage,
                            containerElement: this.formInput,
                            darkMode: document.documentElement.classList.contains('dark-mode'),
                            textDirection: this.wysiwygTextDirection,
                Severity: Major
                Found in resources/js/components/page-comments.js and 1 other location - About 2 hrs to fix
                resources/js/components/page-comment.js on lines 65..72

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

                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

                export function isCut(
                  key: string,
                  shiftKey: boolean,
                  metaKey: boolean,
                  ctrlKey: boolean,
                Severity: Major
                Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts and 1 other location - About 2 hrs to fix
                resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 921..935

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

                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

                export function isCopy(
                  key: string,
                  shiftKey: boolean,
                  metaKey: boolean,
                  ctrlKey: boolean,
                Severity: Major
                Found in resources/js/wysiwyg/lexical/core/LexicalUtils.ts and 1 other location - About 2 hrs to fix
                resources/js/wysiwyg/lexical/core/LexicalUtils.ts on lines 937..951

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

                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 init has 49 lines of code (exceeds 25 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

                  Method processAccessTokenCallback has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function processAccessTokenCallback(OidcAccessToken $accessToken, OidcProviderSettings $settings): User
                      {
                          $idTokenText = $accessToken->getIdToken();
                          $idToken = new OidcIdToken(
                              $idTokenText,
                  Severity: Minor
                  Found in app/Access/Oidc/OidcService.php - About 1 hr to fix

                    Function position has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function position(): void {
                        invariant(rootDOMNode !== null, 'Unexpected null rootDOMNode');
                        invariant(parentDOMNode !== null, 'Unexpected null parentDOMNode');
                        const {left: rootLeft, top: rootTop} = rootDOMNode.getBoundingClientRect();
                        const parentDOMNode_ = parentDOMNode;
                    Severity: Minor
                    Found in resources/js/wysiwyg/lexical/utils/positionNodeOnRange.ts - About 1 hr to fix

                      Function $appendNodesToJSON has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function $appendNodesToJSON(
                        editor: LexicalEditor,
                        selection: BaseSelection | null,
                        currentNode: LexicalNode,
                        targetArray: Array<BaseSerializedNode> = [],
                      Severity: Minor
                      Found in resources/js/wysiwyg/lexical/clipboard/clipboard.ts - About 1 hr to fix

                        Function $insertDataTransferForRichText has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function $insertDataTransferForRichText(
                          dataTransfer: DataTransfer,
                          selection: BaseSelection,
                          editor: LexicalEditor,
                        ): void {
                        Severity: Minor
                        Found in resources/js/wysiwyg/lexical/clipboard/clipboard.ts - About 1 hr to fix

                          Function $handleIndent has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function $handleIndent(listItemNode: ListItemNode): void {
                            // go through each node and decide where to move it.
                            const removed = new Set<NodeKey>();
                          
                            if (isNestedListNode(listItemNode) || removed.has(listItemNode.getKey())) {
                          Severity: Minor
                          Found in resources/js/wysiwyg/lexical/list/formatList.ts - About 1 hr to fix

                            Function onClick has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function onClick(event: PointerEvent, editor: LexicalEditor): void {
                              updateEditor(editor, () => {
                                const selection = $getSelection();
                                const domSelection = getDOMSelection(editor._window);
                                const lastSelection = $getPreviousSelection();
                            Severity: Minor
                            Found in resources/js/wysiwyg/lexical/core/LexicalEvents.ts - About 1 hr to fix

                              Function applyTextFormatFromStyle has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function applyTextFormatFromStyle(
                                style: CSSStyleDeclaration,
                                shouldApply?: TextFormatType,
                              ) {
                                const fontWeight = style.fontWeight;
                              Severity: Minor
                              Found in resources/js/wysiwyg/lexical/core/nodes/LexicalTextNode.ts - About 1 hr to fix

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

                                    test('$isLinkNode()', async () => {
                                      const {editor} = testEnv;
                                
                                      await editor.update(() => {
                                        const linkNode = new LinkNode('');
                                resources/js/wysiwyg/lexical/link/__tests__/unit/LexicalAutoLinkNode.test.ts on lines 479..485
                                resources/js/wysiwyg/lexical/rich-text/__tests__/unit/LexicalHeadingNode.test.ts on lines 170..176

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

                                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