BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

        for (const cell of cells) {
            rowSize += cell.getColSpan() || 1;
            if (cell.getRowSpan() > 1) {
                throw Error('Cannot copy rows with merged cells');
            }
Severity: Major
Found in resources/js/wysiwyg/utils/table-copy-paste.ts and 1 other location - About 1 hr to fix
resources/js/wysiwyg/utils/table-copy-paste.ts on lines 156..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 56.

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

    protected function validateTokenClaims(string $clientId): void
    {
        // 1. The Issuer Identifier for the OpenID Provider (which is typically obtained during Discovery)
        // MUST exactly match the value of the iss (issuer) Claim.
        // Already done in parent.
Severity: Minor
Found in app/Access/Oidc/OidcIdToken.php - About 1 hr to fix

    Function setupListeners has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        setupListeners() {
            const navHandler = new KeyboardNavigationHandler(
                this.list,
                () => {
                    this.input.focus();
    Severity: Minor
    Found in resources/js/components/auto-suggest.js - About 1 hr to fix

      Function saveComment has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          saveComment(event) {
              event.preventDefault();
              event.stopPropagation();
      
              const loading = getLoading();
      Severity: Minor
      Found in resources/js/components/page-comments.js - About 1 hr to fix

        Method store has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function store(Request $request)
            {
                $this->checkPermission('users-manage');
        
                $authMethod = config('auth.method');
        Severity: Minor
        Found in app/Users/Controllers/UserController.php - About 1 hr to fix

          Function createDomForFile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              createDomForFile(file) {
                  const image = elem('img', {src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.224 7.373a.924.924 0 0 0-.92.925l-.006 7.404c0 .509.412.925.921.925h5.557a.928.928 0 0 0 .926-.925v-5.553l-2.777-2.776Zm3.239 3.239V8.067l2.545 2.545z' style='fill:%23000;fill-opacity:.75'/%3E%3C/svg%3E"});
                  const status = elem('div', {class: 'dropzone-file-item-status'}, []);
                  const progress = elem('div', {class: 'dropzone-file-item-progress'});
                  const imageWrap = elem('div', {class: 'dropzone-file-item-image-wrap'}, [image]);
          Severity: Minor
          Found in resources/js/components/dropzone.js - About 1 hr to fix

            Function paste has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function paste(editor, options, event) {
                const clipboard = new Clipboard(event.clipboardData || event.dataTransfer);
            
                // Don't handle the event ourselves if no items exist of contains table-looking data
                if (!clipboard.hasItems() || clipboard.containsTabularData()) {
            Severity: Minor
            Found in resources/js/wysiwyg-tinymce/drop-paste-handling.js - About 1 hr to fix

              Method createManyJointPermissions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function createManyJointPermissions(array $originalEntities, array $roles)
                  {
                      $entities = $this->entitiesToSimpleEntities($originalEntities);
                      $jointPermissions = [];
              
              
              Severity: Minor
              Found in app/Permissions/JointPermissionBuilder.php - About 1 hr to fix

                Function setup has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    setup() {
                        // Options
                        this.uploadedTo = this.$opts.uploadedTo;
                
                        // Element References
                Severity: Minor
                Found in resources/js/components/image-manager.js - About 1 hr to fix

                  Method attempt has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function attempt(array $credentials = [], $remember = false)
                      {
                          $username = $credentials['username'];
                          $userDetails = $this->ldapService->getUserDetails($username);
                  
                  
                  Severity: Minor
                  Found in app/Access/Guards/LdapSessionGuard.php - About 1 hr to fix

                    Function wrapContinuousInlines has 26 lines of code (exceeds 25 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

                      Function importDOM has 26 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/nodes/custom-heading.ts - About 1 hr to fix

                        Function action has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            async action(formData, context: EditorUiContext) {
                                context.editor.update(() => {
                                    const table = $getTableFromSelection($getSelection());
                                    if (!table) {
                                        return;
                        Severity: Minor
                        Found in resources/js/wysiwyg/ui/defaults/forms/tables.ts - About 1 hr to fix

                          Method show has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function show(Request $request, ActivityQueries $activities, string $slug)
                              {
                                  $shelf = $this->queries->findVisibleBySlugOrFail($slug);
                                  $this->checkOwnablePermission('bookshelf-view', $shelf);
                          
                          
                          Severity: Minor
                          Found in app/Entities/Controllers/BookshelfController.php - About 1 hr to fix

                            Function forChild has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    forChild: (lexicalNode, parentLexicalNode) => {
                                        if ($isTableCellNode(parentLexicalNode) && !$isElementNode(lexicalNode)) {
                                            const paragraphNode = $createParagraphNode();
                                            if (
                                                $isLineBreakNode(lexicalNode) &&
                            Severity: Minor
                            Found in resources/js/wysiwyg/nodes/custom-table-cell.ts - About 1 hr to fix

                              Function getLastTextNode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function getLastTextNode(startingNode: Node) {
                                let node = startingNode;
                              
                                mainLoop: while (node !== null) {
                                  if (node !== startingNode && node.nodeType === 3) {
                              Severity: Minor
                              Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts - About 1 hr to fix

                                Function getNextTextNode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function getNextTextNode(startingNode: Node) {
                                  let node = startingNode;
                                
                                  mainLoop: while (node !== null) {
                                    if (node !== startingNode && node.nodeType === 3) {
                                Severity: Minor
                                Found in resources/js/wysiwyg/lexical/selection/__tests__/utils/index.ts - About 1 hr to fix

                                  Function forChild has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      forChild: (lexicalNode, parentLexicalNode) => {
                                        if ($isTableCellNode(parentLexicalNode) && !$isElementNode(lexicalNode)) {
                                          const paragraphNode = $createParagraphNode();
                                          if (
                                            $isLineBreakNode(lexicalNode) &&
                                  Severity: Minor
                                  Found in resources/js/wysiwyg/lexical/table/LexicalTableCellNode.ts - About 1 hr to fix

                                    Function choice has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        choice(translation: string, count: number, replacements: Record<string, string> = {}): string {
                                            const splitText = translation.split('|');
                                            const exactCountRegex = /^{([0-9]+)}/;
                                            const rangeRegex = /^\[([0-9]+),([0-9*]+)]/;
                                            let result = null;
                                    Severity: Minor
                                    Found in resources/js/services/translations.ts - About 1 hr to fix

                                      Function $parseSerializedNodeImpl has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                      function $parseSerializedNodeImpl<
                                        SerializedNode extends InternalSerializedNode,
                                      >(
                                        serializedNode: SerializedNode,
                                        registeredNodes: RegisteredNodes,
                                      Severity: Minor
                                      Found in resources/js/wysiwyg/lexical/core/LexicalUpdates.ts - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language