grommet/grommet-ferret

View on GitHub
server/generator.js

Summary

Maintainability
D
2 days
Test Coverage

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';
Severity: Minor
Found in server/generator.js - About 6 hrs to fix

    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 &&
    Severity: Major
    Found in server/generator.js - About 2 hrs to fix

      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',
      Severity: Minor
      Found in server/generator.js - About 1 hr to fix

        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++) {
        Severity: Minor
        Found in server/generator.js - About 1 hr to fix

        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) {
        Severity: Minor
        Found in server/generator.js - About 1 hr to fix

          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++) {
          Severity: Minor
          Found in server/generator.js - About 1 hr to fix

            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,
            Severity: Minor
            Found in server/generator.js - About 1 hr to fix

              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) {
              Severity: Minor
              Found in server/generator.js - About 1 hr to fix

                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;
                Severity: Major
                Found in server/generator.js - About 45 mins to fix

                  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,
                  Severity: Minor
                  Found in server/generator.js - About 45 mins to fix

                  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);
                  Severity: Major
                  Found in server/generator.js - About 40 mins to fix

                    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) {
                    Severity: Minor
                    Found in server/generator.js - About 35 mins to fix

                    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) {
                    Severity: Minor
                    Found in server/generator.js - About 25 mins to fix

                    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

                    There are no issues that match your filters.

                    Category
                    Status