anyone-oslo/pages

View on GitHub

Showing 71 of 137 total issues

Function Grid has 202 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function Grid(props: Props) {
  const { primary, images, deleted, setDeleted } = props.state;

  const containerRef = useRef();
  const error = useToastStore((state) => state.error);
Severity: Major
Found in app/javascript/components/ImageGrid/Grid.tsx - About 1 day to fix

    Function Options has 155 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function Options(props: OptionsProps) {
      const { state, dispatch, authors, statuses } = props;
    
      const { page, locale, templates } = state;
    
    
    Severity: Major
    Found in app/javascript/components/PageForm/Options.tsx - About 6 hrs to fix

      Function PageTree has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function PageTree({ dir, locale, pages, permissions }: Props) {
        const [state, dispatch] = usePageTree(pages, locale, dir, permissions);
      
        const [dragging, setDragging] = useState(false);
        const [dragState, setDragState] = useState<DragState | null>(null);
      Severity: Minor
      Found in app/javascript/components/PageTree.tsx - About 5 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 List has 134 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function List(props: Props) {
        const { collection, deleted, setDeleted } = props.state;
        const locales = props.locales ? Object.keys(props.locales) : [props.locale];
      
        const uploadAttachment = (file: File) => {
      Severity: Major
      Found in app/javascript/components/Attachments/List.tsx - About 5 hrs to fix

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

        export default function ImageUploader(props: Props) {
          const [uploading, setUploading] = useState(false);
          const [dragover, setDragover] = useState(false);
          const [state, setState] = useState<State>({
            image: props.image,
        Severity: Major
        Found in app/javascript/components/ImageUploader.tsx - About 5 hrs to fix

          Function Node has 126 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function Node(props: Props) {
            const { id, state, dispatch, dragging, onDragStart } = props;
            const { dir, locale } = state;
            const node = state.nodes[id];
            const page = node.record;
          Severity: Major
          Found in app/javascript/components/PageTree/Node.tsx - About 5 hrs to fix

            Function PageForm has 126 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function PageForm(props: Props) {
              const [state, dispatch] = usePage({
                locales: props.locales,
                locale: props.locale,
                page: props.page,
            Severity: Major
            Found in app/javascript/components/PageForm.tsx - About 5 hrs to fix

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

              export default function Attachment(props: Props) {
                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 ImageUploader has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                Open

                export default function ImageUploader(props: Props) {
                  const [uploading, setUploading] = useState(false);
                  const [dragover, setDragover] = useState(false);
                  const [state, setState] = useState<State>({
                    image: props.image,
                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 AttachmentEditor has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function AttachmentEditor(props: Props) {
                  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 GridImage has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function GridImage(props: Props) {
                    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 applyTabs has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function applyTabs() {
                      const tabLinks: HTMLAnchorElement[] = Array.from(
                        document.querySelectorAll(".content-tabs li a")
                      );
                      const tabs: HTMLDivElement[] = Array.from(
                    Severity: Minor
                    Found in app/javascript/features/contentTabs.ts - 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 Form has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function Form(props: Props) {
                      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 drag has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          (e: MouseEvent) => {
                            if (!dragState) {
                              return;
                            } else if (!dragging) {
                              const distance =
                      Severity: Major
                      Found in app/javascript/components/PageTree.tsx - About 2 hrs to fix

                        Function RichTextArea has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export default function RichTextArea({
                          id,
                          name,
                          value: initialValue,
                          rows: initialRows,
                        Severity: Minor
                        Found in app/javascript/components/RichTextArea.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 DateRangeSelect has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export default function DateRangeSelect(props: Props) {
                          const { disabled, disableTime, objectName } = props;
                        
                          const [uncontrolledStartsAt, setUncontrolledStartsAt] = useState(
                            parseDate(props.startsAt)
                        Severity: Major
                        Found in app/javascript/components/DateRangeSelect.tsx - About 2 hrs to fix

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

                          export default function Toolbar(props: Props) {
                            const { cropping } = props.cropState;
                          
                            const aspectRatios: Array<[string, Ratio]> = [
                              ["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<T>(
                              collections: Drag.Collection<T>[],
                              onDragEnd: (dragState: Drag.State<T>, files: File[]) => void
                            ): [
                              Drag.State<T>,
                            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: Props) {
                                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 FocalPoint has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

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