Showing 77 of 77 total issues
Function schema
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
static schema(app, Sequelize) {
const sEnum = Sequelize.ENUM
const schema = {
title: {
type: Sequelize.STRING,
Function createOrUpdateDevices
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
createOrUpdateDevices(device, criteria) {
const plugin = getCurrentPlugin()
//app.log.debug(plugin)
let promise
Function startVoiceCommands
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
startVoiceCommands() {
if (this.voiceCommand) {
this.voiceCommand.stop();
}
Function setValue
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
setValue(deviceId, data) {
if (process.env.DEMO_MODE) {
return this.app.orm.Device.findById(deviceId).then(device => {
if (device) {
const key = data.key
Identical blocks of code found in 2 locations. Consider refactoring. Open
const manageErrors = (app, error) => {
app.log.error(error)
if (app.env.NODE_ENV !== 'production') {
app.log.warn('this payload error is return for development purpose only and will be only log on production')
return error
- 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 71.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
const manageErrors = (app, error) => {
app.log.error(error)
if (app.env.NODE_ENV !== 'production') {
app.log.warn('this payload error is return for development purpose only and will be only log on production')
return error
- 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 71.
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
Function getAdditionalGroupDevice
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
getAdditionalGroupDevice(roomId, devices, wantedType) {
const groupDevices = []
if (!wantedType || wantedType === this.app.lisa.DEVICE_TYPE.LIGHT) {
const lights = devices.filter(devices => devices.type === this.app.lisa.DEVICE_TYPE.LIGHT)
if (roomId && lights.length > 1) {
Function getStorePlugins
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getStorePlugins(req, res) {
const footprintService = this.app.services.FootprintService
const installedPlugins = await footprintService.find('plugin', {}, {})
const plugins = [
{
Function protect
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
protect(req, res, next) {
const header = req.headers['device-id']
const nextPolicy = () => this.app.policies['Passport'].jwt(req, res, next)
const checkHeaderKnownDevice = () => {
return this.app.orm.Device.findAll({
Function config
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
static config() {
return {
options: {
instanceMethods: {
toJSON: function () {
Function schema
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
static schema(app, Sequelize) {
return {
name: {
type: Sequelize.STRING,
allowNull: false
- Read upRead up
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 _translateSettings
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
_translateSettings(lang, settings) {
const translatedSettings = ['labelText', 'text', 'hintText', 'errorText', 'counterText', 'helperText', 'prefixText', 'suffixText']
if (settings) {
for (const setting in settings) {
if(typeof settings[setting] === 'object') {
- Read upRead up
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 findAssociation
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
findAssociation(req, res) {
const footprintService = this.app.services.FootprintService
const favoritesService = this.app.services.FavoritesService
const options = this.app.packs.express.getOptionsFromQuery(req.query)
const criteria = this.app.packs.express.getCriteriaFromQuery(req.query)
Identical blocks of code found in 2 locations. Consider refactoring. Open
const reqStream = request(req.query.url, err => {
if (err) {
this.log.error(err)
res.status(500).end()
}
- 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 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
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
reqStream = request(req.query.url, err => {
if (err) {
this.log.error(err)
res.status(500).end()
}
- 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 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
- 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
Function config
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
static config (app, Sequelize) {
return {
options: {
classMethods: {
associate: (models) => {
Function getOrderedDeviceForRoom
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
getOrderedDeviceForRoom(roomId, userId) {
const promises = [
this.app.orm.Dashboard.find({
where: {
roomId: roomId,
Function checkHeaderKnownDevice
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const checkHeaderKnownDevice = () => {
return this.app.orm.Device.findAll({
where: {
pluginName: 'lisa-plugin-voice'
}
Function saveDevicesOrderForRoom
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
saveDevicesOrderForRoom(roomId, userId, widgetsOrder) {
return this.app.orm.Dashboard.find({
where: {
roomId: roomId,
userId: userId
Function config
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
static config(app, Sequelize) {
return {
options: {
hooks: {
afterCreate: (values, options, fn) => {