makeomatic/ms-files

View on GitHub

Showing 128 of 128 total issues

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

    } else if (actionTypeOrValue.exists !== undefined) {
      if (numericProps.includes(propName)) {
        query.push(`@${propName}:[-inf +inf]`);
      } else {
        query.push(`-@${propName}:""`);
Severity: Major
Found in src/actions/list.js and 1 other location - About 1 hr to fix
src/actions/list.js on lines 431..461

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

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

    } else if (actionTypeOrValue.isempty !== undefined) {
      if (numericProps.includes(propName)) {
        query.push(`-@${propName}:[-inf +inf]`);
      } else {
        query.push(`@${propName}:""`);
Severity: Major
Found in src/actions/list.js and 1 other location - About 1 hr to fix
src/actions/list.js on lines 425..461

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

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

module.exports = function finishPost(props) {
  const { amqp, config } = this;
  const { updateMetadata, audience, exportAudience } = config.users;
  const { exported, sourceSHA } = props;

Severity: Minor
Found in src/custom/cappasity-process-pre.js - About 1 hr to fix

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

      const upperRange = actionTypeOrValue.lte || actionTypeOrValue.lt
        ? (
          actionTypeOrValue.lte
            ? `${actionTypeOrValue.lte}`
            : `(${actionTypeOrValue.lt}`
    Severity: Major
    Found in src/actions/list.js and 1 other location - About 1 hr to fix
    src/actions/list.js on lines 62..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 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 listFiles has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    async function listFiles({ params }) {
      const timer = perf('list', { thunk: false });
    
      const {
        redis,
    Severity: Minor
    Found in src/actions/list.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

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

      const lowerRange = actionTypeOrValue.gte || actionTypeOrValue.gt
        ? (
          actionTypeOrValue.gte
            ? `${actionTypeOrValue.gte}`
            : `(${actionTypeOrValue.gt}`
    Severity: Major
    Found in src/actions/list.js and 1 other location - About 1 hr to fix
    src/actions/list.js on lines 70..76

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

    module.exports = function uploadPost(props) {
      const { amqp, config } = this;
      const { getMetadata, audience, exportAudience } = config.users;
    
      return Promise
    Severity: Minor
    Found in src/custom/cappasity-upload-post.js - About 1 hr to fix

      Function performUpdate has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const performUpdate = async (amqp, file) => {
          const { name, uploadId } = file;
      
          if (filter && filter.test(name) !== true) {
            console.info('[skip] %s -> %s because of %s', uploadId, name, argv.filter);
      Severity: Minor
      Found in bin/apply-sku.js - About 1 hr to fix

        Function setupChannel has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          setupChannel(resourceId) {
            const bucket = this._bucket;
            const gcs = this._gcs;
            const { id, config } = this._config.bucket.channel;
        
        
        Severity: Minor
        Found in src/providers/gce.js - About 1 hr to fix

          Function finishPost has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function finishPost(fileData, lock) {
            const { amqp, config } = this;
            const { process: { prefix, postfix: { process: route }, timeout: { process: timeout } } } = config;
            const { export: exportSettings } = fileData;
          
          
          Severity: Minor
          Found in src/custom/cappasity-process-post.js - About 1 hr to fix

            Function iterateOverUploadedFiles has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async function iterateOverUploadedFiles(service, lock, opts = {}) {
              const { amqp, redis, provider, config: { uploadTTL, router } } = service;
              const { offset = 0, limit = 10 } = opts;
              const route = `${router.routes.prefix}.finish`;
            
            
            Severity: Minor
            Found in src/actions/sync.js - About 1 hr to fix

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

                const { isPublic, temp, tags, redis, hasTags, uploadedAt, order, maxInterval, username, modelType } = ctx;
              Severity: Major
              Found in src/actions/list.js and 1 other location - About 1 hr to fix
              src/actions/upload.js on lines 52..63

              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

                const {
                  meta,
                  username,
                  temp,
                  unlisted,
              Severity: Major
              Found in src/actions/upload.js and 1 other location - About 1 hr to fix
              src/actions/list.js on lines 82..82

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

              module.exports = async function postProcess(offset = 0, uploadedAt = moment().subtract(1, 'hour').valueOf()) {
                const filter = {
                  status: {
                    eq: STATUS_UPLOADED,
                  },
              Severity: Minor
              Found in src/post-process.js - About 1 hr to fix

                Function subscribe has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async subscribe(handler) {
                    assert(this._pubsub, '@google-cloud/pubsub not initialized');
                
                    // extract config
                    const { pubsub } = this._config.bucket.channel;
                Severity: Minor
                Found in src/providers/gce.js - About 1 hr to fix

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

                  async function uploadedIndexAt(service) {
                    const { redis, config, log } = service;
                    const masterNode = getRedisMasterNode(redis, config);
                  
                    let iter = 0;
                  Severity: Minor
                  Found in src/migrations/uploaded-at-index/index.js - About 1 hr to fix

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

                        .try(function verifyUploadData() {
                          if (!props[FILES_EXPORT_FIELD]) {
                            return null;
                          }
                    
                    
                    Severity: Minor
                    Found in src/custom/cappasity-upload-post.js - About 1 hr to fix

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

                      async function nameToNameNormalized(service) {
                        const { redis: masterNode, log } = service;
                        let iter = 0;
                      
                        const stream = masterNode.sscanStream(FILES_INDEX, {
                      Severity: Minor
                      Found in src/migrations/name-to-name-normalized/index.js - About 1 hr to fix

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

                            } else if (actionTypeOrValue.eq) {
                              query.push(`@${propName}:{ $f_${propName}_eq }`);
                              params.push(`f_${propName}_eq`, actionTypeOrValue.eq);
                            } else if (actionTypeOrValue.ne) {
                              query.push(`-@${propName}:{ $f_${propName}_ne }`);
                        Severity: Minor
                        Found in src/actions/list.js and 1 other location - About 55 mins to fix
                        src/actions/list.js on lines 440..461

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

                        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

                            } else if (actionTypeOrValue.ne) {
                              query.push(`-@${propName}:{ $f_${propName}_ne }`);
                              params.push(`f_${propName}_ne`, actionTypeOrValue.ne);
                            } else if (actionTypeOrValue.match) {
                              const varName = `f_${propName.replace(/\|/g, '_')}_m`;
                        Severity: Minor
                        Found in src/actions/list.js and 1 other location - About 55 mins to fix
                        src/actions/list.js on lines 437..461

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

                        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