anyone-oslo/pages

View on GitHub

Showing 130 of 130 total issues

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 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 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>, StartDrag<T>, Listeners] {
        const [dragState, setDragState] = useState<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

        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

        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

        Function applyTabs has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function applyTabs() {
          const tabLinks: HTMLAnchorElement[] = Array.from(
            document.querySelectorAll(".content-tabs li a")
          );
          const tabs: HTMLDivElement[] = Array.from(
        Severity: Major
        Found in app/javascript/features/contentTabs.ts - About 2 hrs to fix

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

          export default function FocalPoint(props: Props) {
            const { width, height } = props;
            const { state, dispatch } = useImageCropperContext();
          
            const [dragging, setDragging] = useState(false);
          Severity: Major
          Found in app/javascript/components/ImageCropper/FocalPoint.tsx - About 2 hrs to fix

            Function DateTimeSelect has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function DateTimeSelect(props: Props) {
              const { name, disabled, disableTime, onChange, value } = props;
            
              const [timeString, setTimeString] = useState(timeToString(value));
            
            
            Severity: Major
            Found in app/javascript/components/DateTimeSelect.tsx - About 2 hrs to fix

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

                        <LabelledField
                          htmlFor="page_redirect_to"
                          label="Redirect"
                          errors={errorsOn(page, "redirect_to")}>
                          <input
              Severity: Major
              Found in app/javascript/components/PageForm/Options.tsx and 1 other location - About 2 hrs to fix
              app/javascript/components/PageForm/Options.tsx on lines 164..175

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

              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

                        <LabelledField
                          htmlFor="page_unique_name"
                          label="Unique name"
                          errors={errorsOn(page, "unique_name")}>
                          <input
              Severity: Major
              Found in app/javascript/components/PageForm/Options.tsx and 1 other location - About 2 hrs to fix
              app/javascript/components/PageForm/Options.tsx on lines 176..187

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

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

              export default function Block(props: Props) {
                const { block, errors, onChange, lang, dir, value } = props;
              
                const handleChange = (
                  evt: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLSelectElement>
              Severity: Major
              Found in app/javascript/components/PageForm/Block.tsx - About 2 hrs to fix

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

                export default function Node(props: Props) {
                  const { state, dispatch } = usePageTreeContext();
                  const { id, dragging, onDragStart } = props;
                  const { dir, locale } = state;
                  const node = state.nodes[id];
                Severity: Minor
                Found in app/javascript/components/PageTree/Node.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 Grid has a Cognitive Complexity of 16 (exceeds 5 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: Minor
                Found in app/javascript/components/ImageGrid/Grid.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 Dates has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function Dates() {
                  const { state, dispatch } = usePageFormContext();
                  const { datesEnabled, page } = state;
                
                  const toggleAllDay = () => {
                Severity: Minor
                Found in app/javascript/components/PageForm/Dates.tsx - About 1 hr to fix

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

                  function insertAdjacentNode<T>(
                    state: State<T>,
                    sibling: Id,
                    node: Node<T>,
                    offset: number = 0
                  Severity: Major
                  Found in app/javascript/components/PageTree/tree.ts and 1 other location - About 1 hr to fix
                  app/javascript/components/PageTree/tree.ts on lines 114..123

                  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

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

                            <select name="locale" value={locale} onChange={handleChangeLocale}>
                              {Object.keys(locales).map((key) => (
                                <option key={`locale-${key}`} value={key}>
                                  {locales[key].name}
                                </option>
                  Severity: Major
                  Found in app/javascript/components/ImageEditor/Form.tsx and 1 other location - About 1 hr to fix
                  app/javascript/components/Attachments/AttachmentEditor.tsx on lines 65..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 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

                  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 50..56

                  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

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

                  export function insertAdjacent<T>(
                    state: State<T>,
                    sibling: Id,
                    record: T,
                    offset: number = 0
                  Severity: Major
                  Found in app/javascript/components/PageTree/tree.ts and 1 other location - About 1 hr to fix
                  app/javascript/components/PageTree/tree.ts on lines 125..134

                  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

                  Function reducer has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function reducer(state: Crop.State, action: Crop.Action): Crop.State {
                    const {
                      crop_start_x,
                      crop_start_y,
                      crop_width,
                  Severity: Minor
                  Found in app/javascript/components/ImageCropper/useCrop.ts - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language