anyone-oslo/pages

View on GitHub

Showing 130 of 130 total issues

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

        <label className="check-box">
          <input
            name="page[pinned]"
            type="checkbox"
            onChange={handleChecked("pinned")}
Severity: Major
Found in app/javascript/components/PageForm/Options.tsx and 2 other locations - About 1 hr to fix
app/javascript/components/PageForm/Options.tsx on lines 130..138
app/javascript/components/PageForm/Options.tsx on lines 139..147

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 3 locations. Consider refactoring.
Open

            <label className="check-box">
              <input
                name="page[feed_enabled]"
                type="checkbox"
                onChange={handleChecked("feed_enabled")}
Severity: Major
Found in app/javascript/components/PageForm/Options.tsx and 2 other locations - About 1 hr to fix
app/javascript/components/PageForm/Options.tsx on lines 96..104
app/javascript/components/PageForm/Options.tsx on lines 139..147

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

export function updatePage(
  state: State,
  id: Tree.Id,
  dispatch: React.Dispatch<Action>,
  attributes: Partial<PageRecord>
Severity: Minor
Found in app/javascript/components/PageTree/usePageTree.ts - About 1 hr to fix

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

              <input
                name={`${attributeName(r)}[attachment_id]`}
                type="hidden"
                value={(r.image && r.image.id) || ""}
              />
    Severity: Major
    Found in app/javascript/components/ImageGrid/Deleted.tsx and 1 other location - About 1 hr to fix
    app/javascript/components/Attachments/Deleted.tsx on lines 14..18

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

    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

              <input
                name={`${attributeName(r)}[attachment_id]`}
                type="hidden"
                value={(r.attachment && r.attachment.id) || ""}
              />
    Severity: Major
    Found in app/javascript/components/Attachments/Deleted.tsx and 1 other location - About 1 hr to fix
    app/javascript/components/ImageGrid/Deleted.tsx on lines 14..18

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

    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
              id="page_user_id"
              name="page[user_id]"
              onChange={handleChange("user_id")}
              value={page.user_id}>
    Severity: Major
    Found in app/javascript/components/PageForm/Options.tsx and 1 other location - About 1 hr to fix
    app/javascript/components/PageForm/Block.tsx on lines 52..58

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

    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 onChange={handleChange} {...commonOptions}>
            {options.map((opt) => (
              <option key={opt[1]} value={opt[1]}>
                {opt[0]}
              </option>
    Severity: Major
    Found in app/javascript/components/PageForm/Block.tsx and 1 other location - About 1 hr to fix
    app/javascript/components/PageForm/Options.tsx on lines 83..93

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

    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 (crop.crop_start_y + crop.crop_height > state.image.real_height) {
        crop.crop_height = state.image.real_height - crop.crop_start_y;
      }
    Severity: Major
    Found in app/javascript/components/ImageCropper/useCrop.ts and 1 other location - About 1 hr to fix
    app/javascript/components/ImageCropper/useCrop.ts on lines 170..172

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

    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 (crop.crop_start_x + crop.crop_width > state.image.real_width) {
        crop.crop_width = state.image.real_width - crop.crop_start_x;
      }
    Severity: Major
    Found in app/javascript/components/ImageCropper/useCrop.ts and 1 other location - About 1 hr to fix
    app/javascript/components/ImageCropper/useCrop.ts on lines 174..176

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

    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 useDragUploader has a Cognitive Complexity of 10 (exceeds 5 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: Minor
    Found in app/javascript/components/drag/useDragUploader.ts - About 1 hr 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

      const deleted = state.deleted.map((a) => {
        return { id: a.id, attachment_id: a.attachment.id, _destroy: "true" };
      });
    Severity: Major
    Found in app/javascript/components/PageForm/pageParams.ts and 1 other location - About 1 hr to fix
    app/javascript/components/PageForm/pageParams.ts on lines 66..68

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

    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

      const deleted = state.deleted.map((i) => {
        return { id: i.id, image_id: i.image.id, _destroy: "true" };
      });
    Severity: Major
    Found in app/javascript/components/PageForm/pageParams.ts and 1 other location - About 1 hr to fix
    app/javascript/components/PageForm/pageParams.ts on lines 36..38

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

    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 (parent) {
            if (l.dataset.tab == tab) {
              parent.classList.add("current");
            } else {
              parent.classList.remove("current");
    Severity: Major
    Found in app/javascript/features/contentTabs.ts and 1 other location - About 1 hr to fix
    app/javascript/features/contentTabs.ts on lines 27..33

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

    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 3 locations. Consider refactoring.
    Open

      const copyEmbed = (evt: MouseEvent) => {
        evt.preventDefault();
        copyToClipboard(`[attachment:${attachment.id}]`);
        notice("Embed code copied to clipboard");
      };
    Severity: Major
    Found in app/javascript/components/Attachments/Attachment.tsx and 2 other locations - About 1 hr to fix
    app/javascript/components/Attachments/AttachmentEditor.tsx on lines 37..41
    app/javascript/components/ImageGrid/GridImage.tsx on lines 50..54

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

    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 3 locations. Consider refactoring.
    Open

      const copyEmbed = (evt: MouseEvent) => {
        evt.preventDefault();
        copyToClipboard(`[image:${image.id}]`);
        notice("Embed code copied to clipboard");
      };
    Severity: Major
    Found in app/javascript/components/ImageGrid/GridImage.tsx and 2 other locations - About 1 hr to fix
    app/javascript/components/Attachments/Attachment.tsx on lines 41..45
    app/javascript/components/Attachments/AttachmentEditor.tsx on lines 37..41

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

    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

        tabs.forEach((t) => {
          if (t.dataset.tab == tab) {
            t.classList.remove("hidden");
          } else {
            t.classList.add("hidden");
    Severity: Major
    Found in app/javascript/features/contentTabs.ts and 1 other location - About 1 hr to fix
    app/javascript/features/contentTabs.ts on lines 18..24

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

    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 3 locations. Consider refactoring.
    Open

      const copyEmbedCode = (evt: MouseEvent) => {
        evt.preventDefault();
        copyToClipboard(`[attachment:${attachment.id}]`);
        notice("Embed code copied to clipboard");
      };
    Severity: Major
    Found in app/javascript/components/Attachments/AttachmentEditor.tsx and 2 other locations - About 1 hr to fix
    app/javascript/components/Attachments/Attachment.tsx on lines 41..45
    app/javascript/components/ImageGrid/GridImage.tsx on lines 50..54

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

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

    export default function useCrop(
      image: Images.Resource
    ): [Crop.State, (action: Crop.Action) => void, string] {
      const initialState: Crop.State = {
        aspect: null,
    Severity: Minor
    Found in app/javascript/components/ImageCropper/useCrop.ts - About 1 hr to fix

      Function pageImages has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function pageImages(state: Images.GridState) {
        const primary = state.primary.draggables
          .filter((r) => r !== "Files")
          .map((r: Drag.Draggable<Images.Record>, i: number) => {
            const pi = r.record;
      Severity: Minor
      Found in app/javascript/components/PageForm/pageParams.ts - About 1 hr to fix

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

          const handleChangeLocale = (evt: React.ChangeEvent<HTMLSelectElement>) => {
            dispatch({ type: "setLocale", payload: evt.target.value });
          };
        Severity: Major
        Found in app/javascript/components/ImageEditor/Form.tsx and 2 other locations - About 1 hr to fix
        app/javascript/components/ImageEditor/Form.tsx on lines 28..32
        app/javascript/components/ImageEditor/Form.tsx on lines 34..36

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

        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