mongaku/mongaku

View on GitHub
src/views/Record.js

Summary

Maintainability
F
5 days
Test Coverage

File Record.js has 695 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// @flow
/* global PhotoSwipe, PhotoSwipeUI_Default */

const React = require("react");

Severity: Major
Found in src/views/Record.js - About 1 day to fix

    Function clusterImages has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

    const clusterImages = (records: Array<RecordType>) => {
        const sourceRecord = records[0];
        const rows = [
            {
                record: sourceRecord,
    Severity: Minor
    Found in src/views/Record.js - About 6 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 clusterImages has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const clusterImages = (records: Array<RecordType>) => {
        const sourceRecord = records[0];
        const rows = [
            {
                record: sourceRecord,
    Severity: Major
    Found in src/views/Record.js - About 3 hrs to fix

      Function renderCarousel has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          renderCarousel() {
              const {record} = this.props;
              const {gettext} = this.context;
              const {curPos} = this.state;
              return (
      Severity: Minor
      Found in src/views/Record.js - About 1 hr to fix

        Function TypeView has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        const TypeView = ({
            value,
            url,
            typeSchema,
        }: {
        Severity: Minor
        Found in src/views/Record.js - 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

        Avoid deeply nested control flow statements.
        Open

                            if (searchSlot.noMatch && searchSlot.images.length > 0) {
                                if (searchSlot.images.length >= needed) {
                                    while (
                                        searchSlot.images.length > 0 &&
                                        slot.images.length < slot.expected
        Severity: Major
        Found in src/views/Record.js - About 45 mins to fix

          Avoid too many return statements within this function.
          Open

                  return <FixedStringView value={value} url={url} />;
          Severity: Major
          Found in src/views/Record.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return null;
            Severity: Major
            Found in src/views/Record.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return <NameView value={value} url={url} multiple={multiple} />;
              Severity: Major
              Found in src/views/Record.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return (
                            <FixedStringView
                                value={value}
                                url={url}
                                multiline={typeSchema.multiline}
                Severity: Major
                Found in src/views/Record.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return <YearRangeView value={value} url={url} />;
                  Severity: Major
                  Found in src/views/Record.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return <FixedStringView value={value} url={value} />;
                    Severity: Major
                    Found in src/views/Record.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return <FixedStringView value={value} url={url} />;
                      Severity: Major
                      Found in src/views/Record.js - About 30 mins to fix

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

                                <div className="details">
                                    <div className="wrap">
                                        <span>
                                            {format(gettext("Score: %(score)s"), {score: score})}
                                        </span>
                        Severity: Major
                        Found in src/views/Record.js and 1 other location - About 4 hrs to fix
                        src/views/Upload.js on lines 87..103

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

                        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

                                        <a
                                            className="right carousel-control"
                                            href="javascript: void 0"
                                            role="button"
                                            onClick={() => this.toggleImage(curPos + 1)}
                        Severity: Major
                        Found in src/views/Record.js and 1 other location - About 2 hrs to fix
                        src/views/Record.js on lines 149..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 91.

                        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

                                        <a
                                            className="left carousel-control"
                                            href="javascript: void 0"
                                            role="button"
                                            onClick={() => this.toggleImage(curPos - 1)}
                        Severity: Major
                        Found in src/views/Record.js and 1 other location - About 2 hrs to fix
                        src/views/Record.js on lines 161..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 91.

                        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

                                <a href={recordModel.getURL}>
                                    <img
                                        src={recordModel.getThumbURL}
                                        alt={recordModel.getTitle}
                                        title={recordModel.getTitle}
                        Severity: Major
                        Found in src/views/Record.js and 1 other location - About 1 hr to fix
                        src/views/Upload.js on lines 78..85

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

                        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

                                                <tr className="plain">
                                                    <td />
                                                    {records.map(record => (
                                                        <Images
                                                            {...props}
                        Severity: Major
                        Found in src/views/Record.js and 1 other location - About 1 hr to fix
                        src/views/Record.js on lines 367..376

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

                        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

                                                <tr className="plain">
                                                    <th />
                                                    {records.map(record => (
                                                        <Title
                                                            {...props}
                        Severity: Major
                        Found in src/views/Record.js and 1 other location - About 1 hr to fix
                        src/views/Record.js on lines 377..386

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

                        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 values = Object.keys(expectedValues).map(id => ({
                                    id,
                                    name: expectedValues[id].name,
                                }));
                        Severity: Minor
                        Found in src/views/Record.js and 1 other location - About 35 mins to fix
                        src/views/EditRecord.js on lines 294..297

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

                        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

                        There are no issues that match your filters.

                        Category
                        Status