Function getAuthHeader
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function getAuthHeader() {
let token
let login
let password
Identical blocks of code found in 2 locations. Consider refactoring. Open
module.exports = function getAuthHeader() {
let token
let login
let password
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Replace '../errors')
with "../errors");
Open
const { MoyskladError } = require('../errors')
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
let token
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
password = options.password
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
login = options.login
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
break
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
break
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace '@wmakeev/base64encode')
with "@wmakeev/base64encode");
Open
const base64encode = require('@wmakeev/base64encode')
- Read upRead up
- Exclude checks
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}`)
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
break
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace 'Не·указан·пароль·для·доступа·к·API')
with "Не·указан·пароль·для·доступа·к·API");
Open
throw new MoyskladError('Не указан пароль для доступа к API')
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace '../getEnvVar')
with "../getEnvVar");
Open
const getEnvVar = require('../getEnvVar')
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace 'MOYSKLAD_TOKEN'
with "MOYSKLAD_TOKEN"
Open
case getEnvVar('MOYSKLAD_TOKEN') != null:
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
break
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
return undefined
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
let login
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace 'MOYSKLAD_LOGIN'
with "MOYSKLAD_LOGIN"
Open
case getEnvVar('MOYSKLAD_LOGIN') != null:
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace 'MOYSKLAD_LOGIN')
with "MOYSKLAD_LOGIN");
Open
login = getEnvVar('MOYSKLAD_LOGIN')
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
return bearerAuth(token)
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace 'use·strict'
with "use·strict";
Open
'use strict'
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
let password
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace 'MOYSKLAD_PASSWORD')
with "MOYSKLAD_PASSWORD");
Open
password = getEnvVar('MOYSKLAD_PASSWORD')
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
const bearerAuth = token => `Bearer ${token}`
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
return basicAuth(login, password)
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
token = options.token
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
const options = this.getOptions()
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace 'MOYSKLAD_TOKEN')
with "MOYSKLAD_TOKEN");
Open
token = getEnvVar('MOYSKLAD_TOKEN')
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Insert ;
Open
}
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/