anyone-oslo/pages

View on GitHub

Showing 117 of 117 total issues

Function Form has 69 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 useDragUploader has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function useDragUploader(
      collections: Drag.Collection[],
      onDragEnd: (dragState: Drag.State, files: File[]) => void
    ) {
      const initialState: Drag.State = {
    Severity: Major
    Found in app/javascript/components/drag/useDragUploader.ts - 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 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 ImageCropper has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

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

          export async function postJson(url: string, data: Record<string, unknown>) {
            const response = await fetch(url, {
              ...jsonFetchOptions(),
              method: "POST",
              body: data ? JSON.stringify(data) : null
          Severity: Major
          Found in app/javascript/lib/request.ts and 1 other location - About 2 hrs to fix
          app/javascript/lib/request.ts on lines 30..37

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

          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 async function putJson(url: string, data: Record<string, unknown>) {
            const response = await fetch(url, {
              ...jsonFetchOptions(),
              method: "PUT",
              body: data ? JSON.stringify(data) : null
          Severity: Major
          Found in app/javascript/lib/request.ts and 1 other location - About 2 hrs to fix
          app/javascript/lib/request.ts on lines 21..28

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

          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 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<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 Draggable.tsx has 261 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

                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

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

                  RichTextArea.propTypes = {
                    id: PropTypes.string,
                    name: PropTypes.string,
                    value: PropTypes.string,
                    rows: PropTypes.number,
                  Severity: Major
                  Found in app/javascript/components/RichTextArea.jsx and 1 other location - About 2 hrs to fix
                  app/javascript/components/ImageGrid.jsx on lines 279..287

                  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

                  ImageGrid.propTypes = {
                    attribute: PropTypes.string,
                    locale: PropTypes.string,
                    locales: PropTypes.object,
                    records: PropTypes.array,
                  Severity: Major
                  Found in app/javascript/components/ImageGrid.jsx and 1 other location - About 2 hrs to fix
                  app/javascript/components/RichTextArea.jsx on lines 236..244

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

                    render() {
                      return (
                        <div className="date-range-select">
                          <input
                            type="hidden"
                  Severity: Minor
                  Found in app/javascript/components/DateRangeSelect.jsx - About 1 hr to fix

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

                        this.tabTargets.forEach((t) => {
                          if (t.dataset.tab == tab) {
                            t.classList.remove("hidden");
                          } else {
                            t.classList.add("hidden");
                    Severity: Major
                    Found in app/javascript/controllers/MainController.ts and 1 other location - About 1 hr to fix
                    app/javascript/controllers/MainController.ts on lines 60..66

                    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

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

                        this.linkTargets.forEach((l) => {
                          if (l.dataset.tab == tab) {
                            l.classList.add("current");
                          } else {
                            l.classList.remove("current");
                    Severity: Major
                    Found in app/javascript/controllers/MainController.ts and 1 other location - About 1 hr to fix
                    app/javascript/controllers/MainController.ts on lines 68..74

                    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

                    Function ImageEditor has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function ImageEditor(props: Props) {
                      const [cropState, dispatch, croppedImage] = useCrop(props.image);
                      const [locale, setLocale] = useState(props.locale);
                      const [localizations, setLocalizations] = useState({
                        caption: props.image.caption || {},
                    Severity: Minor
                    Found in app/javascript/components/ImageEditor.tsx - About 1 hr to fix

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

                        actions() {
                          const statusLabel = this.node().status != 2 ? "Publish" : "Hide";
                          const statusIcon = this.node().status != 2 ? "check" : "ban";
                      
                          if (this.node().editing) {
                      Severity: Minor
                      Found in app/javascript/components/PageTree/Node.tsx - About 1 hr to fix

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

                                    <select
                                      name="locale"
                                      value={locale}
                                      onChange={(e) => setLocale(e.target.value)}>
                                      {Object.keys(locales).map((key) => (
                        Severity: Major
                        Found in app/javascript/components/Attachments/AttachmentEditor.tsx and 1 other location - About 1 hr to fix
                        app/javascript/components/ImageEditor/Form.tsx on lines 46..52

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

                        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