anyone-oslo/pages

View on GitHub

Showing 117 of 117 total issues

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

      <div className="deleted">
        {deleted.map((r) => (
          <span className="deleted-image" key={r.id}>
            <input name={`${attrName(r)}[id]`} type="hidden" value={r.id} />
            <input
Severity: Major
Found in app/javascript/components/ImageGrid.jsx and 1 other location - About 1 day to fix
app/javascript/components/Attachments.jsx on lines 144..160

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

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

      <div className="deleted">
        {deleted.map((r) => (
          <span className="deleted-attachment" key={r.id}>
            <input name={`${attrName(r)}[id]`} type="hidden" value={r.id} />
            <input
Severity: Major
Found in app/javascript/components/Attachments.jsx and 1 other location - About 1 day to fix
app/javascript/components/ImageGrid.jsx on lines 258..274

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

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

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

    function getFiles(dt: DataTransfer): File[] {
      const files: File[] = [];
      if (dt.items) {
        for (let i = 0; i < dt.items.length; i++) {
          if (dt.items[i].kind == "file") {
    Severity: Major
    Found in app/javascript/components/drag/useDragUploader.ts and 1 other location - About 7 hrs to fix
    app/javascript/components/ImageUploader.tsx on lines 20..34

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

    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

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

    function getFiles(dt: DataTransfer): File[] {
      const files: File[] = [];
      if (dt.items) {
        for (let i = 0; i < dt.items.length; i++) {
          if (dt.items[i].kind == "file") {
    Severity: Major
    Found in app/javascript/components/ImageUploader.tsx and 1 other location - About 7 hrs to fix
    app/javascript/components/drag/useDragUploader.ts on lines 16..30

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

    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

            <div className="date">
              {this.renderDateSelect(
                "ends-at",
                this.state.endsAt,
                this.changeEndsAt
    Severity: Major
    Found in app/javascript/components/DateRangeSelect.jsx and 1 other location - About 6 hrs to fix
    app/javascript/components/DateRangeSelect.jsx on lines 146..162

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

    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

            <div className="date">
              {this.renderDateSelect(
                "starts-at",
                this.state.startsAt,
                this.changeStartsAt
    Severity: Major
    Found in app/javascript/components/DateRangeSelect.jsx and 1 other location - About 6 hrs to fix
    app/javascript/components/DateRangeSelect.jsx on lines 164..180

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

    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 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: Props) {
        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

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

                <select
                  value={date.getFullYear()}
                  onChange={(e) => handleChange({ year: e.target.value })}
                  disabled={this.props.disabled}>
                  {this.yearOptions().map((y) => (
        Severity: Major
        Found in app/javascript/components/DateRangeSelect.jsx and 1 other location - About 4 hrs to fix
        app/javascript/components/DateRangeSelect.jsx on lines 109..118

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

        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
                  value={date.getDate()}
                  onChange={(e) => handleChange({ date: e.target.value })}
                  disabled={this.props.disabled}>
                  {this.dayOptions().map((d) => (
        Severity: Major
        Found in app/javascript/components/DateRangeSelect.jsx and 1 other location - About 4 hrs to fix
        app/javascript/components/DateRangeSelect.jsx on lines 119..128

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

        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

        File Node.tsx has 363 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 drag has a Cognitive Complexity of 27 (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 Attachment has 95 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 AttachmentEditor has 93 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: Props) {
                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

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

                      <div className="field embed-code">
                        <label>Embed code</label>
                        <input
                          type="text"
                          value={`[attachment:${attachment.id}]`}
              Severity: Major
              Found in app/javascript/components/Attachments/AttachmentEditor.tsx and 1 other location - About 3 hrs to fix
              app/javascript/components/ImageEditor/Form.tsx on lines 38..42

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

              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

                    <div className="field embed-code">
                      <label>Embed code</label>
                      <input type="text" value={`[image:${image.id}]`} disabled={true} />
                      {copySupported() && <button onClick={copyEmbedCode}>Copy</button>}
                    </div>
              Severity: Major
              Found in app/javascript/components/ImageEditor/Form.tsx and 1 other location - About 3 hrs to fix
              app/javascript/components/Attachments/AttachmentEditor.tsx on lines 96..104

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

              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 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 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
                  Severity
                  Category
                  Status
                  Source
                  Language