wmakeev/moysklad

View on GitHub
src/methods/getAuthHeader.js

Summary

Maintainability
C
1 day
Test Coverage
A
100%

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

module.exports = function getAuthHeader() {
  let token
  let login
  let password

Severity: Minor
Found in src/methods/getAuthHeader.js - About 1 hr to fix

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

    module.exports = function getAuthHeader() {
      let token
      let login
      let password
    
    
    Severity: Major
    Found in src/methods/getAuthHeader.js and 1 other location - About 1 day to fix
    bundle/umd/moysklad.js on lines 1127..1164

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

    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

    Replace '../errors') with "../errors");
    Open

    const { MoyskladError } = require('../errors')
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

      let token
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

          password = options.password
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

          login = options.login
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

          break
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

          break
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Replace '@wmakeev/base64encode') with "@wmakeev/base64encode");
    Open

    const base64encode = require('@wmakeev/base64encode')
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Replace 'Basic·'·+·base64encode(${login}:${password}) with "Basic·"·+·base64encode(${login}:${password});
    Open

      'Basic ' + base64encode(`${login}:${password}`)
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

          break
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Replace 'Не·указан·пароль·для·доступа·к·API') with "Не·указан·пароль·для·доступа·к·API");
    Open

        throw new MoyskladError('Не указан пароль для доступа к API')
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Replace '../getEnvVar') with "../getEnvVar");
    Open

    const getEnvVar = require('../getEnvVar')
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Replace 'MOYSKLAD_TOKEN' with "MOYSKLAD_TOKEN"
    Open

        case getEnvVar('MOYSKLAD_TOKEN') != null:
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

          break
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

          return undefined
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

      let login
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Replace 'MOYSKLAD_LOGIN' with "MOYSKLAD_LOGIN"
    Open

        case getEnvVar('MOYSKLAD_LOGIN') != null:
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Replace 'MOYSKLAD_LOGIN') with "MOYSKLAD_LOGIN");
    Open

          login = getEnvVar('MOYSKLAD_LOGIN')
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

        return bearerAuth(token)
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Replace 'use·strict' with "use·strict";
    Open

    'use strict'
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

      let password
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Replace 'MOYSKLAD_PASSWORD') with "MOYSKLAD_PASSWORD");
    Open

          password = getEnvVar('MOYSKLAD_PASSWORD')
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

    const bearerAuth = token => `Bearer ${token}`
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

        return basicAuth(login, password)
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

          token = options.token
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

      const options = this.getOptions()
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Replace 'MOYSKLAD_TOKEN') with "MOYSKLAD_TOKEN");
    Open

          token = getEnvVar('MOYSKLAD_TOKEN')
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    Insert ;
    Open

    }
    Severity: Minor
    Found in src/methods/getAuthHeader.js by eslint

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

    There are no issues that match your filters.

    Category
    Status