makeomatic/ms-files

View on GitHub

Showing 150 of 150 total issues

Function initResumableUpload has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async initResumableUpload(opts, uploadParams) {
    const { allowedOrigins, alwaysRequireSignedURLs, cloudflare, config, maxDurationSeconds } = this;
    const { options, overrideNotificationUrl } = config;
    const { accountId } = options;
    const { metadata: { [FILES_CONTENT_LENGTH_FIELD]: contentLength } } = opts;
Severity: Minor
Found in src/providers/cloudflare-stream.js - About 35 mins 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 cloudflareWebhookAction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function cloudflareWebhookAction(request) {
  const { redis } = this;
  const body = request.transportRequest.payload;
  const signature = request.headers['webhook-signature'];
  const provider = this.providersByAlias['cloudflare-stream'];
Severity: Minor
Found in src/actions/cloudflare-stream.js - About 35 mins 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 getPlayerOpts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const getPlayerOpts = (id, { uploadType, c_ver: modelVersion, packed }, apiDomain) => {
  let version;

  // if upload type isn't simple - means we have old mesh upload
  // generally c_ver -> 1.x.x
Severity: Minor
Found in src/custom/cappasity-info-post.js - About 35 mins 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 initUpload has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async initUpload(opts, uploadParams) {
    const { allowedOrigins, alwaysRequireSignedURLs, cloudflare, config, maxDurationSeconds } = this;
    const { options, overrideNotificationUrl } = config;
    const { accountId } = options;
    const { metadata: { [FILES_CONTENT_LENGTH_FIELD]: contentLength } } = opts;
Severity: Minor
Found in src/providers/cloudflare-stream.js - About 35 mins 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 uploadedIndexAt has a Cognitive Complexity of 7 (exceeds 5 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 35 mins 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

    referenceInfoMap[refUploadId] = {
      hasNft,
      hasReferences,
      referenced,
      owner,
Severity: Minor
Found in src/utils/reference.js and 1 other location - About 35 mins to fix
src/actions/list.js on lines 210..220

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

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

  const {
    redis,
    criteria,
    order,
    strFilter,
Severity: Minor
Found in src/actions/list.js and 1 other location - About 35 mins to fix
src/utils/reference.js on lines 59..69

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

Function downloadSelector has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function downloadSelector(opts, file, headers = {}) {
  if (needToUploadToCloudflare(opts, file)) {
    return selectCloudflareStreamProvider(this);
  }

Severity: Minor
Found in src/custom/cappasity-select-bucket.js - About 25 mins 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 preProcessMetadata has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function preProcessMetadata(data) {
  const { description, alias } = data;

  // Trim extra spaces in case of typo
  if (description != null && typeof description === 'string') {
Severity: Minor
Found in src/actions/update.js - About 25 mins 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 uploadSelector has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function uploadSelector(opts, file, headers = {}) {
  if (needToUploadToCloudflare(opts, file)) {
    return selectCloudflareStreamProvider(this);
  }

Severity: Minor
Found in src/custom/cappasity-select-bucket.js - About 25 mins 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 nameToNameNormalized has a Cognitive Complexity of 6 (exceeds 5 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 25 mins 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 removeFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function removeFile({ params }) {
  const { filename, username, softDelete } = params;
  const { redis, log } = this;
  const key = `${FILES_DATA}:${filename}`;

Severity: Minor
Found in src/actions/remove.js - About 25 mins 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 remapData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function remapData(field, index) {
  const value = this.data[index];
  if (hasOwnProperty.call(JSON_FIELDS, field)) {
    this.output[field] = safeParse(value, []);
  } else if (hasOwnProperty.call(STRINGIFY_FIELDS, field)) {
Severity: Minor
Found in src/utils/fetch-data.js - About 25 mins 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

Parsing error: The keyword 'const' is reserved
Open

const {

For more information visit Source: http://eslint.org/docs/rules/

Parsing error: The keyword 'const' is reserved
Open

const Promise = require('bluebird');
Severity: Minor
Found in src/utils/fetch-data.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Parsing error: The keyword 'const' is reserved
Open

const { HttpStatusError } = require('common-errors');
Severity: Minor
Found in src/utils/is-unlisted.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Parsing error: The keyword 'const' is reserved
Open

const Promise = require('bluebird');
Severity: Minor
Found in src/utils/process.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Parsing error: The keyword 'const' is reserved
Open

const config = {

For more information visit Source: http://eslint.org/docs/rules/

Parsing error: The keyword 'const' is reserved
Open

const Promise = require('bluebird');
Severity: Minor
Found in src/index.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Parsing error: The keyword 'const' is reserved
Open

const { getRedisMasterNode } = require('../../utils/get-redis-master-node');

For more information visit Source: http://eslint.org/docs/rules/

Severity
Category
Status
Source
Language