BookStackApp/BookStack

View on GitHub

Showing 1,485 of 1,485 total issues

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

  while (
    (previousNode = node.getPreviousSibling()) !== null &&
    $isTextNode(previousNode) &&
    previousNode.isSimpleText() &&
    !previousNode.isUnmergeable()
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalNormalization.ts and 1 other location - About 1 hr to fix
resources/js/wysiwyg/lexical/core/LexicalNormalization.ts on lines 72..86

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

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

  while (
    (nextNode = node.getNextSibling()) !== null &&
    $isTextNode(nextNode) &&
    nextNode.isSimpleText() &&
    !nextNode.isUnmergeable()
Severity: Major
Found in resources/js/wysiwyg/lexical/core/LexicalNormalization.ts and 1 other location - About 1 hr to fix
resources/js/wysiwyg/lexical/core/LexicalNormalization.ts on lines 53..67

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

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 (wrappingElement) {
          target.append(wrappingElement);
        } else {
          for (let i = 0; i < elements.length; i++) {
            const element = elements[i];
Severity: Major
Found in resources/js/wysiwyg/lexical/selection/range-selection.ts and 1 other location - About 1 hr to fix
resources/js/wysiwyg/lexical/selection/range-selection.ts on lines 347..355

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

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

  exportJSON(): SerializedElementNode {
    return {
      children: [],
      direction: this.getDirection(),
      format: this.getFormatType(),
resources/js/wysiwyg/lexical/core/nodes/LexicalRootNode.ts on lines 108..117

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

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 (anchorOffet === 0 && !this.isEmpty() && selection) {
      const paragraph = $createParagraphNode();
      paragraph.select();
      this.replace(paragraph, true);
    }
Severity: Major
Found in resources/js/wysiwyg/lexical/rich-text/index.ts and 1 other location - About 1 hr to fix
resources/js/wysiwyg/nodes/callout.ts on lines 108..112

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

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

    setupBookSortable(bookContainer) {
        const sortElems = Array.from(bookContainer.querySelectorAll('.sort-list, .sortable-page-sublist'));

        const bookGroupConfig = {
            name: 'book',
Severity: Minor
Found in resources/js/components/book-sort.js - About 1 hr to fix

    Function gatherPlugins has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function gatherPlugins(options) {
        const plugins = [
            'image',
            'table',
            'link',
    Severity: Minor
    Found in resources/js/wysiwyg-tinymce/config.js - About 1 hr to fix

      Method rules has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function rules(int $userId = null): array
          {
              return [
                  'create' => [
                      'name'  => ['required', 'string', 'min:1', 'max:100'],
      Severity: Minor
      Found in app/Users/Controllers/UserApiController.php - About 1 hr to fix

        Function getSetupCallback has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getSetupCallback(options) {
            return function setupCallback(editor) {
                function editorChange() {
                    if (options.darkMode) {
                        editor.contentDocument.documentElement.classList.add('dark-mode');
        Severity: Minor
        Found in resources/js/wysiwyg-tinymce/config.js - About 1 hr to fix

          Function handleDropdown has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function handleDropdown(options: HandleDropdownParams) {
              const {menu, toggle, onClose, onOpen, showOnHover} = options;
              let clickListener: Function|null = null;
          
              const hide = () => {
          Severity: Minor
          Found in resources/js/wysiwyg/ui/framework/helpers/dropdowns.ts - About 1 hr to fix

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

                public function show(string $bookSlug, string $pageSlug)
                {
                    try {
                        $page = $this->queries->findVisibleBySlugsOrFail($bookSlug, $pageSlug);
                    } catch (NotFoundException $e) {
            Severity: Minor
            Found in app/Entities/Controllers/PageController.php - About 1 hr to fix

              Method loadModelsFromSortMap has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function loadModelsFromSortMap(BookSortMap $sortMap): array
                  {
                      $modelMap = [];
                      $ids = [
                          'chapter' => [],
              Severity: Minor
              Found in app/Entities/Tools/BookContents.php - About 1 hr to fix

                Function updateDOM has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  updateDOM(
                    prevNode: LinkNode,
                    anchor: LinkHTMLElementType,
                    config: EditorConfig,
                  ): boolean {
                Severity: Minor
                Found in resources/js/wysiwyg/lexical/link/index.ts - About 1 hr to fix

                  Function $handleNormalizationMergeConflicts has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function $handleNormalizationMergeConflicts(
                    binding: Binding,
                    normalizedNodes: Set<NodeKey>,
                  ): void {
                    // We handle the merge operations here
                  Severity: Minor
                  Found in resources/js/wysiwyg/lexical/yjs/SyncEditorStates.ts - About 1 hr to fix

                    Function moveSelectionPointToSibling has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function moveSelectionPointToSibling(
                      point: PointType,
                      node: LexicalNode,
                      parent: ElementNode,
                      prevSibling: LexicalNode | null,
                    Severity: Minor
                    Found in resources/js/wysiwyg/lexical/core/LexicalSelection.ts - About 1 hr to fix

                      Function simpleDiffWithCursor has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export default function simpleDiffWithCursor(
                        a: string,
                        b: string,
                        cursor: number,
                      ): {index: number; insert: string; remove: number} {
                      Severity: Minor
                      Found in resources/js/wysiwyg/lexical/core/shared/simpleDiffWithCursor.ts - About 1 hr to fix

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

                            setupListeners() {
                                const keyboardNavHandler = new KeyboardNavigationHandler(this.container, event => {
                                    this.hide();
                                    this.toggle.focus();
                                    if (!this.bubbleEscapes) {
                        Severity: Minor
                        Found in resources/js/components/dropdown.js - About 1 hr to fix

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

                              setupListeners() {
                                  // Copy on copy button click
                                  this.includeButton.addEventListener('click', () => copyTextToClipboard(this.includeInput.value));
                                  this.linkButton.addEventListener('click', () => copyTextToClipboard(this.linkInput.value));
                          
                          
                          Severity: Minor
                          Found in resources/js/components/pointer.js - About 1 hr to fix

                            Method handle has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function handle(PermissionsUpdater $permissionsUpdater, BookshelfQueries $queries): int
                                {
                                    $shelfSlug = $this->option('slug');
                                    $cascadeAll = $this->option('all');
                                    $shelves = null;
                            Severity: Minor
                            Found in app/Console/Commands/CopyShelfPermissionsCommand.php - About 1 hr to fix

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

                                  async action(formData, context: EditorUiContext) {
                                      const selectedNode: MediaNode|null = await (new Promise((res, rej) => {
                                          context.editor.getEditorState().read(() => {
                                              const node = $getNodeFromSelection($getSelection(), $isMediaNode);
                                              res(node as MediaNode|null);
                              Severity: Minor
                              Found in resources/js/wysiwyg/ui/defaults/forms/objects.ts - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language