mongaku/mongaku

View on GitHub

Showing 336 of 336 total issues

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

                    <div className="form-group">
                        <label htmlFor="usernames">
                            {gettext("Usernames and Passwords (CSV, required)")}
                        </label>
                        <textarea
Severity: Major
Found in src/views/AddUsers.js and 1 other location - About 2 hrs to fix
src/views/AddSources.js on lines 37..50

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

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

    getImages(callback) {
        async.mapLimit(
            this.images,
            4,
            (id, callback) => {
Severity: Major
Found in src/schemas/Record.js and 1 other location - About 2 hrs to fix
src/schemas/Upload.js on lines 92..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 82.

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="form-group">
                        <label htmlFor="sources">
                            {gettext(
                                "Source IDs, Full Names, Short Names, and URLs (CSV, required)",
                            )}
Severity: Major
Found in src/views/AddSources.js and 1 other location - About 2 hrs to fix
src/views/AddUsers.js on lines 35..46

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

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

    getImages(callback) {
        async.mapLimit(
            this.images,
            4,
            (id, callback) => {
Severity: Major
Found in src/schemas/Upload.js and 1 other location - About 2 hrs to fix
src/schemas/Record.js on lines 200..212

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

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

    processRecords(callback) {
        const Record = record(this.type);
        const incomingIDs = {};

        const results = this.results;
Severity: Major
Found in src/schemas/RecordImport.js - About 2 hrs to fix

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

        fromFile(batch, file, callback) {
            const Image = models("Image");
            const Source = models("Source");
    
            const filePath = file.path || file;
    Severity: Major
    Found in src/schemas/Image.js - About 2 hrs to fix

      Function TypeFilter has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      const TypeFilter = ({
          name,
          value,
          allValues,
          typeSchema,
      Severity: Minor
      Found in src/views/SearchForm.js - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function exports has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = (
          lang: string,
          options: Options,
          translations: {
              [message: string]: ?Array<string>,
      Severity: Minor
      Found in src/views/utils.js - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      File ImageImport.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      const os = require("os");
      const fs = require("fs");
      const path = require("path");
      
      const glob = require("glob");
      Severity: Minor
      Found in src/schemas/ImageImport.js - About 2 hrs to fix

        Function filter has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            filter(value) {
                const filters = [];
        
                if (value.widthMin) {
                    filters.push({
        Severity: Major
        Found in src/schemas/types/Dimension.js - About 2 hrs to fix

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

                                      if (failed.length > 0) {
                                          qs.push(
                                              `error=${encodeURIComponent(
                                                  i18n.format(
                                                      i18n.gettext(
          Severity: Major
          Found in src/logic/admin.js and 1 other location - About 2 hrs to fix
          src/logic/admin.js on lines 259..275

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

          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 (failed.length > 0) {
                                          qs.push(
                                              `error=${encodeURIComponent(
                                                  i18n.format(
                                                      i18n.gettext(
          Severity: Major
          Found in src/logic/admin.js and 1 other location - About 2 hrs to fix
          src/logic/admin.js on lines 403..419

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

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

          module.exports = (fields, {originalUrl, i18n, user}, callback) => {
              // Collect all the values from the request to construct
              // the search URL and matches later
              // Generate the filters and facets which will be fed in to Elasticsearch
              // to build the query filter and aggregations
          Severity: Minor
          Found in src/logic/shared/search.js - About 2 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

          ImageImport.pre("validate", function(next) {
              // Create the ID if one hasn't been set before
              if (!this._id) {
                  this._id = `${this.source}/${Date.now()}`;
              }
          Severity: Major
          Found in src/schemas/ImageImport.js and 1 other location - About 2 hrs to fix
          src/schemas/RecordImport.js on lines 362..369

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

          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

          RecordImport.pre("validate", function(next) {
              // Create the ID if one hasn't been set before
              if (!this._id) {
                  this._id = `${this.source}/${Date.now()}`;
              }
          Severity: Major
          Found in src/schemas/RecordImport.js and 1 other location - About 2 hrs to fix
          src/schemas/ImageImport.js on lines 313..320

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

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

              updateSimilarity(callback) {
                  // Skip small images
                  if (!this.canIndex()) {
                      return process.nextTick(callback);
                  }
          Severity: Major
          Found in src/schemas/Image.js - About 2 hrs to fix

            Function exports has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = (
                lang: string,
                options: Options,
                translations: {
                    [message: string]: ?Array<string>,
            Severity: Major
            Found in src/views/utils.js - About 2 hrs to fix

              Function routes has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      routes() {
                          const source = (req, res, next) => {
                              const {
                                  params: {source},
                              } = req;
              Severity: Minor
              Found in src/logic/source-admin.js - About 2 hrs to fix

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

                            <ImportResult
                                {...props}
                                id="deleted"
                                title={
                                    state === "completed"
                Severity: Major
                Found in src/views/ImportRecords.js and 2 other locations - About 2 hrs to fix
                src/views/ImportRecords.js on lines 242..253
                src/views/ImportRecords.js on lines 255..266

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

                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

                            <ImportResult
                                {...props}
                                id="changed"
                                title={
                                    state === "completed"
                Severity: Major
                Found in src/views/ImportRecords.js and 2 other locations - About 2 hrs to fix
                src/views/ImportRecords.js on lines 255..266
                src/views/ImportRecords.js on lines 268..279

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

                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