Showing 10,536 of 10,536 total issues

Similar blocks of code found in 15 locations. Consider refactoring.
Open

app.factory('EnergyStorageContainerFirecontrolService', function($http) {
    return {
        getAllEnergyStorageContainerFirecontrols: function(headers, callback) {
            $http.get(getAPI()+'energystoragecontainerfirecontrols', {headers})
            .then(function (response) {
myems-admin/app/services/settings/energystoragecontainer/energystoragecontainerbattery.service.js on lines 2..46
myems-admin/app/services/settings/energystoragecontainer/energystoragecontainergrid.service.js on lines 2..45
myems-admin/app/services/settings/energystoragecontainer/energystoragecontainerhvac.service.js on lines 2..45
myems-admin/app/services/settings/energystoragecontainer/energystoragecontainerload.service.js on lines 2..45
myems-admin/app/services/settings/energystoragecontainer/energystoragecontainerpowerconversionsystem.service.js on lines 2..45
myems-admin/app/services/settings/energystoragecontainer/energystoragecontainerschedule.service.js on lines 2..45
myems-admin/app/services/settings/microgrid/microgridbattery.service.js on lines 2..46
myems-admin/app/services/settings/microgrid/microgridevcharger.service.js on lines 2..46
myems-admin/app/services/settings/microgrid/microgridgenerator.service.js on lines 2..45
myems-admin/app/services/settings/microgrid/microgridgrid.service.js on lines 2..45
myems-admin/app/services/settings/microgrid/microgridheatpump.service.js on lines 2..46
myems-admin/app/services/settings/microgrid/microgridload.service.js on lines 2..45
myems-admin/app/services/settings/microgrid/microgridphotovoltaic.service.js on lines 2..45
myems-admin/app/services/settings/microgrid/microgridpowerconversionsystem.service.js on lines 2..45

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 447.

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

Further Reading

Similar blocks of code found in 15 locations. Consider refactoring.
Open

app.factory('EnergyStorageContainerBatteryService', function($http) {
    return {
        getAllEnergyStorageContainerBatteries: function(headers, callback) {
            $http.get(getAPI()+'energystoragecontainerbatteries', {headers})
            .then(function (response) {
myems-admin/app/services/settings/energystoragecontainer/energystoragecontainerfirecontrol.service.js on lines 2..45
myems-admin/app/services/settings/energystoragecontainer/energystoragecontainergrid.service.js on lines 2..45
myems-admin/app/services/settings/energystoragecontainer/energystoragecontainerhvac.service.js on lines 2..45
myems-admin/app/services/settings/energystoragecontainer/energystoragecontainerload.service.js on lines 2..45
myems-admin/app/services/settings/energystoragecontainer/energystoragecontainerpowerconversionsystem.service.js on lines 2..45
myems-admin/app/services/settings/energystoragecontainer/energystoragecontainerschedule.service.js on lines 2..45
myems-admin/app/services/settings/microgrid/microgridbattery.service.js on lines 2..46
myems-admin/app/services/settings/microgrid/microgridevcharger.service.js on lines 2..46
myems-admin/app/services/settings/microgrid/microgridgenerator.service.js on lines 2..45
myems-admin/app/services/settings/microgrid/microgridgrid.service.js on lines 2..45
myems-admin/app/services/settings/microgrid/microgridheatpump.service.js on lines 2..46
myems-admin/app/services/settings/microgrid/microgridload.service.js on lines 2..45
myems-admin/app/services/settings/microgrid/microgridphotovoltaic.service.js on lines 2..45
myems-admin/app/services/settings/microgrid/microgridpowerconversionsystem.service.js on lines 2..45

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 447.

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

Further Reading

Function generate_excel has a Cognitive Complexity of 127 (exceeds 5 allowed). Consider refactoring.
Open

def generate_excel(report,
                   name,
                   base_period_start_datetime_local,
                   base_period_end_datetime_local,
                   reporting_start_datetime_local,
Severity: Minor
Found in myems-api/excelexporters/equipmentenergyitem.py - About 2 days 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 on_get has a Cognitive Complexity of 126 (exceeds 5 allowed). Consider refactoring.
Open

    def on_get(req, resp):
        access_control(req)
        # Get user inforamtion
        user_uuid = str.strip(req.headers['USER-UUID'])
        cnx_user_db = mysql.connector.connect(**config.myems_user_db)
Severity: Minor
Found in myems-api/reports/microgridlist.py - About 2 days 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 EventManager has 510 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function EventManager(options) { // assumed to be a calendar
    var t = this;
    
    
    // exports
Severity: Major
Found in myems-admin/js/plugins/fullcalendar/fullcalendar.js - About 2 days to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    app.controller('WechatMessageOptionController', function(
        $scope,
        $window,
        $timeout,
        WechatMessageService) {
    myems-admin/app/controllers/fdd/textmessage/textmessageoption.controller.js on lines 3..56

    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 443.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    app.controller('TextMessageOptionController', function(
        $scope,
        $window,
        $timeout,
        TextMessageService) {
    myems-admin/app/controllers/fdd/wechatmessage/wechatmessageoption.controller.js on lines 3..56

    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 443.

    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

    Further Reading

    Function on_get has a Cognitive Complexity of 125 (exceeds 5 allowed). Consider refactoring.
    Open

        def on_get(req, resp):
            access_control(req)
            # Get user inforamtion
            user_uuid = str.strip(req.headers['USER-UUID'])
            cnx_user_db = mysql.connector.connect(**config.myems_user_db)
    Severity: Minor
    Found in myems-api/reports/energystoragepowerstationlist.py - About 2 days 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

    File daterangepicker.js has 1010 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
    * @version: 1.3.21
    * @author: Dan Grossman http://www.dangrossman.info/
    * @copyright: Copyright (c) 2012-2015 Dan Grossman. All rights reserved.
    * @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
    Severity: Major
    Found in myems-admin/js/plugins/daterangepicker/daterangepicker.js - About 2 days to fix

      File EnergyStoragePowerStationDetails.js has 1010 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import React, { Fragment, useState, useEffect } from 'react';
      import {
        Button,
        ButtonGroup,
        Card,

        Function main has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring.
        Open

        def main(logger):
        
            while True:
                # the outermost while loop
                ################################################################################################################
        Severity: Minor
        Found in myems-aggregation/energy_storage_container_billing_charge.py - About 2 days 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 main has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring.
        Open

        def main(logger):
        
            while True:
                # the outermost while loop
                ################################################################################################################
        Severity: Minor
        Found in myems-aggregation/energy_storage_power_station_billing_charge.py - About 2 days 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 main has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring.
        Open

        def main(logger):
        
            while True:
                # the outermost while loop
                ################################################################################################################
        Severity: Minor
        Found in myems-aggregation/microgrid_carbon_discharge.py - About 2 days 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 main has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring.
        Open

        def main(logger):
        
            while True:
                # the outermost while loop
                ################################################################################################################
        Severity: Minor
        Found in myems-aggregation/microgrid_billing_discharge.py - About 2 days 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 main has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring.
        Open

        def main(logger):
        
            while True:
                # the outermost while loop
                ################################################################################################################
        Severity: Minor
        Found in myems-aggregation/energy_storage_container_carbon_charge.py - About 2 days 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 main has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring.
        Open

        def main(logger):
        
            while True:
                # the outermost while loop
                ################################################################################################################
        Severity: Minor
        Found in myems-aggregation/energy_storage_container_billing_discharge.py - About 2 days 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 main has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring.
        Open

        def main(logger):
        
            while True:
                # the outermost while loop
                ################################################################################################################
        Severity: Minor
        Found in myems-aggregation/energy_storage_power_station_carbon_discharge.py - About 2 days 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 main has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring.
        Open

        def main(logger):
        
            while True:
                # the outermost while loop
                ################################################################################################################
        Severity: Minor
        Found in myems-aggregation/energy_storage_container_carbon_discharge.py - About 2 days 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 main has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring.
        Open

        def main(logger):
        
            while True:
                # the outermost while loop
                ################################################################################################################
        Severity: Minor
        Found in myems-aggregation/energy_storage_power_station_carbon_charge.py - About 2 days 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 main has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring.
        Open

        def main(logger):
        
            while True:
                # the outermost while loop
                ################################################################################################################
        Severity: Minor
        Found in myems-aggregation/microgrid_carbon_charge.py - About 2 days 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

        Severity
        Category
        Status
        Source
        Language