imaginerio/narratives

View on GitHub

Showing 79 of 86 total issues

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

  const {
    myNarratives,
    gallery,
    addNarrative,
    modified,
Severity: Major
Found in src/pages/projects.js and 1 other location - About 1 hr to fix
src/pages/signup.js on lines 42..55

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

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 {
    createAccount,
    enterDetails,
    name,
    email,
Severity: Major
Found in src/pages/signup.js and 1 other location - About 1 hr to fix
src/pages/projects.js on lines 61..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 71.

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

            <Form.Input
              name="email"
              label={email}
              type="email"
              value={identity}
Severity: Major
Found in src/pages/login.js and 1 other location - About 1 hr to fix
src/pages/login.js on lines 89..96

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

            <Form.Input
              name="password"
              label={password}
              type="password"
              value={secret}
Severity: Major
Found in src/pages/login.js and 1 other location - About 1 hr to fix
src/pages/login.js on lines 81..88

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

            if (step.data.annotations) {
              setAnnotations({
                type: 'FeatureCollection',
                features: step.data.annotations.map(({ feature }) => JSON.parse(feature)),
              });
Severity: Major
Found in src/components/View/index.jsx and 1 other location - About 1 hr to fix
src/components/Atlas/Context.jsx on lines 87..92

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

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 (data.Slide.annotations) {
        setAnnotations({
          type: 'FeatureCollection',
          features: data.Slide.annotations.map(({ feature }) => JSON.parse(feature)),
        });
Severity: Major
Found in src/components/Atlas/Context.jsx and 1 other location - About 1 hr to fix
src/components/View/index.jsx on lines 96..101

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

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

                {proj.updatedAt && (
                  <span style={{ marginRight: 10 }}>
                    {`${modified}: ${new Date(proj.updatedAt).toLocaleDateString()}`}
                  </span>
                )}
Severity: Major
Found in src/pages/projects.js and 1 other location - About 1 hr to fix
src/pages/projects.js on lines 150..154

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

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

                {proj.createdAt && (
                  <span style={{ marginRight: 10 }}>
                    {`${created}: ${new Date(proj.createdAt).toLocaleDateString()}`}
                  </span>
                )}
Severity: Major
Found in src/pages/projects.js and 1 other location - About 1 hr to fix
src/pages/projects.js on lines 145..149

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

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

  const setMapYear = () => {
    const map = mapRef.current.getMap();
    let style = null;
    try {
      style = map.getStyle();
Severity: Minor
Found in src/components/Atlas/index.jsx - About 1 hr to fix

    Function onUpdate has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function onUpdate(e) {
        const { data, editType } = e;
    
        dispatch(['SET_FEATURES', data]);
    
    
    Severity: Minor
    Found in src/providers/DrawProvider/index.js - About 1 hr to fix

      Function prepareMiddleware has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        prepareMiddleware({ keystone }) {
          const middleware = express();
          middleware.post('/reset', (req, res) => {
            const { email } = req.body;
            return runCustomQuery({
      Severity: Minor
      Found in routes/reset.js - About 1 hr to fix

        Function addInitialUser has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const addInitialUser = async (keystone, context) => {
          // Count existing users
          const {
            data: {
              _allUsersMeta: { count },
        Severity: Minor
        Found in initial-data.js - About 1 hr to fix

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

                    <Layer
                      id="annotation-line-label"
                      type="symbol"
                      filter={['==', '$type', 'LineString']}
                      layout={{ ...labelLayout, 'symbol-placement': 'line' }}
          Severity: Major
          Found in src/components/Atlas/index.jsx and 1 other location - About 1 hr to fix
          src/components/Atlas/index.jsx on lines 246..252

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

          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

                    <Layer
                      id="annotation-polygon-label"
                      type="symbol"
                      filter={['==', '$type', 'Polygon']}
                      layout={{ ...labelLayout, 'symbol-placement': 'point' }}
          Severity: Major
          Found in src/components/Atlas/index.jsx and 1 other location - About 1 hr to fix
          src/components/Atlas/index.jsx on lines 253..259

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

          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 Slide has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          const Slide = ({
            id,
            title,
            index,
            color,
          Severity: Minor
          Found in src/components/Slide/index.jsx - 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

          Function prepareMiddleware has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            prepareMiddleware({ keystone }) {
              const middleware = express();
              middleware.post('/password', (req, res) => {
                const { key, password } = req.body;
                return runCustomQuery({
          Severity: Minor
          Found in routes/password.js - About 1 hr to fix

            Function documentReqs has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              const documentReqs = documents.map(m => {
                const variables = {
                  ...m,
                  firstYear: m.firstyear,
                  lastYear: m.lastyear,
            Severity: Minor
            Found in initial-data.js - About 1 hr to fix

              Function EditPage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              const EditPage = ({ project, statusCode }) => {
                if (statusCode) return <ErrorPage statusCode={statusCode} />;
              
                const [activeSlide, setActiveSlide] = useState(null);
                const [apiLoading, setApiLoading] = useState(false);
              Severity: Minor
              Found in src/pages/edit/[project].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

              Function getMapProps has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const getMapProps = () => {
                  let props = {
                    ref: mapRef,
                    mapboxApiAccessToken: 'pk.eyJ1IjoiYXhpc21hcHMiLCJhIjoieUlmVFRmRSJ9.CpIxovz1TUWe_ecNLFuHNg',
                    mapStyle: '/style/style.json',
              Severity: Minor
              Found in src/components/Atlas/index.jsx - About 1 hr to fix

                Function layers has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        style.layers = style.layers.map(layer => {
                          if (layer.source === 'composite') {
                            const filter =
                              layer.filter && layer.filter[1][0] === 'match' ? layer.filter.slice(0, 2) : ['all'];
                            return {
                Severity: Minor
                Found in src/components/Atlas/index.jsx - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language