makeomatic/ms-files

View on GitHub

Showing 128 of 128 total issues

Function redisSearch has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
Open

async function redisSearch(ctx) {
  // 1. build query
  const indexName = `${ctx.service.config.redis.options.keyPrefix}:${FILES_LIST_SEARCH}`;
  const args = ['FT.SEARCH', indexName];
  const query = [];
Severity: Minor
Found in src/actions/list.js - About 1 day 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 list.js has 489 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const { ActionTransport } = require('@microfleet/plugin-router');
const Promise = require('bluebird');
const fsort = require('redis-filtered-sort');
const perf = require('ms-perf');
const { HttpStatusError, NotImplementedError } = require('common-errors');
Severity: Minor
Found in src/actions/list.js - About 7 hrs to fix

    Function updateMeta has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Open

    async function updateMeta(lock, ctx, params) {
      const { uploadId, username, directOnly, immutable, includeReferences } = params;
      const { redis } = ctx;
      const key = FILES_DATA_INDEX_KEY(uploadId);
      const meta = preProcessMetadata(params.meta);
    Severity: Minor
    Found in src/actions/update.js - About 7 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 redisSearch has 123 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function redisSearch(ctx) {
      // 1. build query
      const indexName = `${ctx.service.config.redis.options.keyPrefix}:${FILES_LIST_SEARCH}`;
      const args = ['FT.SEARCH', indexName];
      const query = [];
    Severity: Major
    Found in src/actions/list.js - About 4 hrs to fix

      Function updateMeta has 115 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function updateMeta(lock, ctx, params) {
        const { uploadId, username, directOnly, immutable, includeReferences } = params;
        const { redis } = ctx;
        const key = FILES_DATA_INDEX_KEY(uploadId);
        const meta = preProcessMetadata(params.meta);
      Severity: Major
      Found in src/actions/update.js - About 4 hrs to fix

        Function interstore has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

        async function interstore(ctx) {
          const { isPublic, temp, tags, redis, hasTags, uploadedAt, order, maxInterval, username, modelType } = ctx;
        
          if (modelType === 'nft') {
            throw new NotImplementedError('nft filter is unavailable');
        Severity: Minor
        Found in src/actions/list.js - About 4 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 interstore has 97 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function interstore(ctx) {
          const { isPublic, temp, tags, redis, hasTags, uploadedAt, order, maxInterval, username, modelType } = ctx;
        
          if (modelType === 'nft') {
            throw new NotImplementedError('nft filter is unavailable');
        Severity: Major
        Found in src/actions/list.js - About 3 hrs to fix

          Function initFileUpload has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

          async function initFileUpload({ params }) {
            const {
              meta,
              username,
              temp,
          Severity: Minor
          Found in src/actions/upload.js - 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

          File cappasity-info-post.js has 315 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // 1. для мешей старый вариант
          // 2. для всех 3д вью - ротэйт опции
          // 3. если 3двью имеет версию 4+ - добавляются зум опции
          
          const flatstr = require('flatstr');
          Severity: Minor
          Found in src/custom/cappasity-info-post.js - About 3 hrs to fix

            Function extractMetadata has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function extractMetadata(params) {
              let sourceSHA;
            
              const {
                files,
            Severity: Minor
            Found in src/custom/cappasity-upload-pre.js - 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 completeFileUpload has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

            async function completeFileUpload({ params }) {
              const { filename } = params;
              const { redis, config, amqp, provider } = this;
              const { prefix } = config.router.routes;
              const uploadPartKey = `${UPLOAD_DATA}:${filename}`;
            Severity: Minor
            Found in src/actions/finish.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 gce.js has 284 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            const Promise = require('bluebird');
            const AbstractFileTransfer = require('ms-files-transport');
            const { get, merge, defaults } = require('lodash');
            const bl = require('bl');
            const assert = require('assert');
            Severity: Minor
            Found in src/providers/gce.js - About 2 hrs to fix

              GCETransport has 23 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class GCETransport extends AbstractFileTransfer {
                constructor(opts = {}) {
                  super();
                  this._config = merge({}, GCETransport.defaultOpts, opts);
                  this._logger = this._config.logger;
              Severity: Minor
              Found in src/providers/gce.js - About 2 hrs to fix

                Function cloneFile has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function cloneFile(lock, ctx, params) {
                  const { uploadId, username, meta } = params;
                  const { redis } = ctx;
                  const uploadKey = FILES_DATA_INDEX_KEY(uploadId);
                  const uploadData = await Promise
                Severity: Major
                Found in src/actions/clone.js - About 2 hrs to fix

                  Function extractMetadata has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function extractMetadata(params) {
                    let sourceSHA;
                  
                    const {
                      files,
                  Severity: Major
                  Found in src/custom/cappasity-upload-pre.js - About 2 hrs to fix

                    Function performProcessing has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const performProcessing = async (lock, service, data) => {
                      const { uploadId } = data;
                      const { redis } = service;
                    
                      let response;
                    Severity: Major
                    Found in src/utils/process.js - About 2 hrs to fix

                      Function verifyReferences has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function verifyReferences(originalMeta, referenceInfoMap, newReferences) {
                        const { uploadId, owner } = originalMeta;
                        const oldReferences = originalMeta[FILES_REFERENCES_FIELD] || [];
                        const added = findAdded(oldReferences, newReferences);
                      
                      
                      Severity: Minor
                      Found in src/utils/reference.js - About 1 hr to fix

                        Function postProcessFile has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                        async function postProcessFile({ params }) {
                          const { uploadId, username, awaitPostActions } = params;
                          const { maxTries } = this.config;
                          const key = `${FILES_DATA}:${uploadId}`;
                        
                        
                        Severity: Minor
                        Found in src/actions/process.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 verifyUploadData has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            .try(function verifyUploadData() {
                              if (uploadType === 'simple' && files.find(isPack)) {
                                meta[FILES_PACKED_FIELD] = '1';
                                return null;
                              }
                        Severity: Minor
                        Found in src/custom/cappasity-upload-pre.js - About 1 hr to fix

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

                          async function getReferenceData(redis, references = []) {
                            const pipeline = redis.pipeline();
                          
                            references.forEach((id) => {
                              pipeline.smembers(FILES_REFERENCED_INDEX_KEY(id));
                          Severity: Minor
                          Found in src/utils/reference.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language