File generator.js
has 454 lines of code (exceeds 250 allowed). Consider refactoring. Open
// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP
import {
addAssociation, addCategory, addResource, getItems, setSettings, setStatus
} from './data';
Function createActivity
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createActivity () {
// associate alerts and tasks with resources
let resources = [];
SCHEMA.filter(category => (
'alerts' !== category.name && 'tasks' !== category.name &&
Function initializeSettings
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initializeSettings () {
const settings = {
description: 'These are the configuration settings for an Ingot.',
state: 'initial', // initial | updating | ready
name: 'cluster PA 4',
Function buildItems
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function buildItems (category) {
let date = new Date();
let count = category.count || RESOURCE_COUNT;
for (var i = 1; i <= count; i++) {
- 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 addUtilization
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function addUtilization (item) {
// If the item came from the generator, copy attributes so each item has
// its own
let attributes = item.attributes || {};
if (item._indexAttributes) {
Function buildItems
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildItems (category) {
let date = new Date();
let count = category.count || RESOURCE_COUNT;
for (var i = 1; i <= count; i++) {
Function buildItem
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildItem (options) { //categoryName, index, name, date) {
const category = options.category;
const resource = {
name: options.name,
Function createAssociations
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createAssociations () {
SCHEMA.forEach(category => {
if (category.hasOwnProperty('associations')) {
for (let name in category.associations) {
Avoid deeply nested control flow statements. Open
if (childIndex < children.length) {
const child = children[childIndex];
addAssociation(name, parent.uri, child.uri);
if (schema.childUriAttribute) {
child[schema.childUriAttribute] = parent.uri;
Function buildItem
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function buildItem (options) { //categoryName, index, name, date) {
const category = options.category;
const resource = {
name: options.name,
- 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
Consider simplifying this complex logical expression. Open
if (resource.status && 'OK' !== resource.status &&
'Disabled' !== resource.status &&
'alerts' !== category.name && 'tasks' !== category.name &&
'appliances' !== category.name) {
alertForResource(resource, options.index);
Function distribute
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function distribute (values) {
let result;
for (var i = 0; i < values.length; i++) {
if (Array.isArray(values[i])) {
if (random(values[i][1]) === 0) {
- 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 addUtilization
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function addUtilization (item) {
// If the item came from the generator, copy attributes so each item has
// its own
let attributes = item.attributes || {};
if (item._indexAttributes) {
- 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"