anyone-oslo/pages

View on GitHub

Showing 77 of 115 total issues

Function ImageGrid has 197 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function ImageGrid(props) {
  const [initPrimary, initImages] = initRecords(props);
  const primary = useDragCollection(initPrimary);
  const images = useDragCollection(initImages);
  const [deleted, setDeleted] = useState([]);
Severity: Major
Found in app/javascript/components/ImageGrid.jsx - About 7 hrs to fix

    Function Attachments has 131 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function Attachments(props) {
      const collection = useDragCollection(props.records);
      const locales =
        props.locales && props.locales.length > 0
          ? Object.keys(props.locales)
    Severity: Major
    Found in app/javascript/components/Attachments.jsx - About 5 hrs to fix

      Function ImageUploader has 128 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function ImageUploader(props: ImageUploaderProps) {
        const [uploading, setUploading] = useState(false);
        const [dragover, setDragover] = useState(false);
        const [image, setImage] = useState(props.image);
        const [src, setSrc] = useState(props.src);
      Severity: Major
      Found in app/javascript/components/ImageUploader.tsx - About 5 hrs to fix

        File Node.tsx has 353 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
           Based on react-ui-tree
           https://github.com/pqx/react-ui-tree
        
           The MIT License (MIT)
        Severity: Minor
        Found in app/javascript/components/PageTree/Node.tsx - About 4 hrs to fix

          Function Attachment has 95 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function Attachment(props: AttachmentProps) {
            const { attributeName, draggable, locales, locale } = props;
            const { record } = draggable;
            const { attachment, uploading } = record;
          
          
          Severity: Major
          Found in app/javascript/components/Attachments/Attachment.tsx - About 3 hrs to fix

            Function AttachmentEditor has 92 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function AttachmentEditor(props: AttachmentEditorProps) {
              const { attachment, locales } = props;
            
              const [locale, setLocale] = useState(props.locale);
              const [localizations, setLocalizations] = useState({
            Severity: Major
            Found in app/javascript/components/Attachments/AttachmentEditor.tsx - About 3 hrs to fix

              Function ImageUploader has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

              export default function ImageUploader(props: ImageUploaderProps) {
                const [uploading, setUploading] = useState(false);
                const [dragover, setDragover] = useState(false);
                const [image, setImage] = useState(props.image);
                const [src, setSrc] = useState(props.src);
              Severity: Minor
              Found in app/javascript/components/ImageUploader.tsx - About 3 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function drag has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

                drag(e: MouseEvent) {
                  if (this._start) {
                    const distance =
                      Math.abs(e.clientX - this._offsetX) +
                      Math.abs(e.clientY - this._offsetY);
              Severity: Minor
              Found in app/javascript/components/PageTree/Draggable.tsx - About 3 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function GridImage has 76 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function GridImage(props: GridImageProps) {
                const { attributeName, draggable } = props;
                const record = draggable.record;
                const image = record.image;
              
              
              Severity: Major
              Found in app/javascript/components/ImageGrid/GridImage.tsx - About 3 hrs to fix

                Function drag has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  drag(e: MouseEvent) {
                    if (this._start) {
                      const distance =
                        Math.abs(e.clientX - this._offsetX) +
                        Math.abs(e.clientY - this._offsetY);
                Severity: Major
                Found in app/javascript/components/PageTree/Draggable.tsx - About 2 hrs to fix

                  Function Form has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function Form(props: FormProps) {
                    const { alternative, caption, image, locale, locales } = props;
                  
                    const closeModal = useModalStore((state) => state.close);
                    const notice = useToastStore((state) => state.notice);
                  Severity: Major
                  Found in app/javascript/components/ImageEditor/Form.tsx - About 2 hrs to fix

                    Function Toolbar has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function Toolbar(props: ToolbarProps) {
                      const { cropping } = props.cropState;
                    
                      const aspectRatios = [
                        ["Free", null],
                    Severity: Major
                    Found in app/javascript/components/ImageCropper/Toolbar.tsx - About 2 hrs to fix

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

                      export default function useDragUploader(
                        collections: DragCollection[],
                        onDragEnd: (dragState: DragState, files: File[]) => void
                      ) {
                        const initialState: DragState = {
                      Severity: Major
                      Found in app/javascript/components/drag/useDragUploader.ts - About 2 hrs to fix

                        Function Attachment has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export default function Attachment(props: AttachmentProps) {
                          const { attributeName, draggable, locales, locale } = props;
                          const { record } = draggable;
                          const { attachment, uploading } = record;
                        
                        
                        Severity: Minor
                        Found in app/javascript/components/Attachments/Attachment.tsx - About 2 hrs to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function ImageCropper has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export default function ImageCropper(props: ImageCropperProps) {
                          const containerRef = useRef<HTMLDivElement>();
                          const [containerSize, setContainerSize] = useState();
                        
                          const handleResize = () => {
                        Severity: Major
                        Found in app/javascript/components/ImageCropper.tsx - About 2 hrs to fix

                          File Draggable.tsx has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          /*
                             Based on react-ui-tree
                             https://github.com/pqx/react-ui-tree
                          
                             The MIT License (MIT)
                          Severity: Minor
                          Found in app/javascript/components/PageTree/Draggable.tsx - About 2 hrs to fix

                            Function FocalPoint has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export default function FocalPoint(props: FocalPointProps) {
                              const { width, height, onChange } = props;
                            
                              const [dragging, setDragging] = useState(false);
                              const [position, setPosition] = useState<Position>({
                            Severity: Major
                            Found in app/javascript/components/ImageCropper/FocalPoint.tsx - About 2 hrs to fix

                              Function actions has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                actions() {
                                  const simple = [
                                    {
                                      name: "bold",
                                      className: "bold",
                              Severity: Major
                              Found in app/javascript/components/RichTextArea.jsx - About 2 hrs to fix

                                File ImageGrid.jsx has 255 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import React, { useRef, useState } from "react";
                                import PropTypes from "prop-types";
                                import FileUploadButton from "./FileUploadButton";
                                import DragElement from "./ImageGrid/DragElement";
                                import FilePlaceholder from "./ImageGrid/FilePlaceholder";
                                Severity: Minor
                                Found in app/javascript/components/ImageGrid.jsx - About 2 hrs to fix

                                  Function ImageGrid has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  export default function ImageGrid(props) {
                                    const [initPrimary, initImages] = initRecords(props);
                                    const primary = useDragCollection(initPrimary);
                                    const images = useDragCollection(initImages);
                                    const [deleted, setDeleted] = useState([]);
                                  Severity: Minor
                                  Found in app/javascript/components/ImageGrid.jsx - About 2 hrs to fix

                                  Cognitive Complexity

                                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                  A method's cognitive complexity is based on a few simple rules:

                                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                  • Code is considered more complex for each "break in the linear flow of the code"
                                  • Code is considered more complex when "flow breaking structures are nested"

                                  Further reading

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language