Showing 35 of 77 total issues
Function exports
has 228 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (function () {
//private
let app
/**
Function exports
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
module.exports = (function () {
//private
let app
/**
- 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 interact
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
interact(infos) {
if (infos.action === 'UNKNOWN') {
return Promise.resolve(infos)
}
else {
Function schema
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
static schema(app, Sequelize) {
return {
name: {
type: Sequelize.STRING,
allowNull: false
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
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)
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) => {