Showing 5,781 of 10,536 total issues

Avoid too many return statements within this function.
Open

    return {k: v for k, v in result.items() if start_datetime_utc <= k <= end_datetime_utc}
Severity: Major
Found in myems-api/core/utilities.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return list(), None, None, None, None, None, None
    Severity: Major
    Found in myems-api/core/utilities.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return
      Severity: Major
      Found in myems-api/core/useractivity.py - About 30 mins to fix

        Function detectVerticalSquash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        var detectVerticalSquash = function detectVerticalSquash(img) {
          var iw = img.naturalWidth;
          var ih = img.naturalHeight;
          var canvas = document.createElement("canvas");
          canvas.width = 1;
        Severity: Minor
        Found in myems-admin/js/plugins/dropzone/dropzone.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

        Function getValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          getValue: function(value) {
            var lengthes = [],
                fullLength = 0,
                l,
                i = 0,
        Severity: Minor
        Found in myems-admin/js/plugins/jvectormap/jquery-jvectormap-2.0.2.min.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

        Function Notifications has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const Notifications = ({ items = rawNotifications.length, children }) => {
          const { loading, data: notifications, setData: setNotifications } = useFakeFetch(rawNotifications);
          const [settingsIsOpen, setSettingsIsOpen] = useState(false);
        
          const toggleSettingsModal = () => setSettingsIsOpen(!settingsIsOpen);
        Severity: Minor
        Found in myems-web/src/components/page/Notifications.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

        Function WizardInput has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const WizardInput = ({
          label,
          id,
          name,
          errors,
        Severity: Minor
        Found in myems-web/src/components/auth/wizard/WizardInput.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

        Function minimalizaSidebar has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function minimalizaSidebar($timeout) {
            return {
                restrict: 'A',
                template: '<a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="" ng-click="minimalize()"><i class="fa fa-bars"></i></a>',
                controller: function ($scope, $element) {
        Severity: Minor
        Found in myems-admin/app/directives/directives.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

        Function Invoice has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const Invoice = () => {
          const [subtotal, setSubtotal] = useState(0);
          const [tax, setTax] = useState(0);
          const [total, setTotal] = useState(0);
          const { loading: invoiceLoading, data: invoice } = useFakeFetch(rawInvoice);
        Severity: Minor
        Found in myems-web/src/components/page/Invoice.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

        Function numberFormatter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export const numberFormatter = (number, fixed = 2) => {
          // Nine Zeroes for Billions
          return Math.abs(Number(number)) >= 1.0e9
            ? (Math.abs(Number(number)) / 1.0e9).toFixed(fixed) + 'B'
            : // Six Zeroes for Millions
        Severity: Minor
        Found in myems-web/src/helpers/utils.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

        Function LastMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const LastMessage = (lastMessage, thread) => {
          const { users } = useContext(ChatContext);
          const user = users.find(({ id }) => id === lastMessage?.senderUserId);
          const name = user?.name.split(' ');
          const lastMassagePreview =
        Severity: Minor
        Found in myems-web/src/components/chat/sidebar/LastMessage.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

        Function IconStatus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const IconStatus = ({ id }) => {
          const { feeds, feedDispatch } = useContext(FeedContext);
        
          const [active, setActive] = useState(false);
          const targetedFeed = feeds.find(feed => feed.id === id);
        Severity: Minor
        Found in myems-web/src/components/feed/IconStatus.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

        Function RegistrationForm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const RegistrationForm = ({ setRedirect, setRedirectUrl, layout, hasLabel }) => {
          // State
          const [name, setName] = useState('');
          const [email, setEmail] = useState('');
          const [password, setPassword] = useState('');
        Severity: Minor
        Found in myems-web/src/components/auth/RegistrationForm.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

        Function ProductAdd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const ProductAdd = () => {
          const { products, productsDispatch } = useContext(ProductContext);
          const [title, setTitle] = useState('');
          const [category, setCategory] = useState('Camera');
          const [files, setFiles] = useState([]);
        Severity: Minor
        Found in myems-web/src/components/e-commerce/ProductAdd.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

        Function EnergyStoragePowerStationTable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const EnergyStoragePowerStationTable = ({ setIsSelected, energyStoragePowerStationList, t }) => {
          const { currency } = useContext(AppContext);
          const energyFormatter = amount => <Fragment>{amount} kWh</Fragment>;
          const capacityFormatter = amount => <Fragment>{amount} kWh</Fragment>;
          const powerFormatter = amount => <Fragment>{amount} kW</Fragment>;

        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 MicrogridDetails has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const MicrogridDetails = ({ setRedirect, setRedirectUrl, t }) => {
          const location = useLocation();
          const microgridUUID = location.search.split('=')[1];
          const { currency } = useContext(AppContext);
        
        
        Severity: Minor
        Found in myems-web/src/components/MyEMS/Microgrid/MicrogridDetails.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

        Function KanbanContainer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const KanbanContainer = () => {
          const { kanbanColumns, UpdateColumnData, modalContent, modal, setModal } = useContext(KanbanContext);
          const containerRef = useRef(null);
        
          // Detect device
        Severity: Minor
        Found in myems-web/src/components/kanban/KanbanContainer.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

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

        def generate_excel(report, space_name, energy_category_name, reporting_start_datetime_local,
                           reporting_end_datetime_local, language):
        
            trans = get_translation(language)
            trans.install()
        Severity: Minor
        Found in myems-api/excelexporters/metertracking.py - 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

        Function int16_to_hhmm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def int16_to_hhmm(actual_value):
            """Convert int16 to time in HH:mm"""
            hh = int(actual_value / 256)
            if hh < 10:
                hh = '0' + str(hh)
        Severity: Minor
        Found in myems-api/core/utilities.py - 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

        Function on_post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def on_post(req, resp, id_):
                """Handles POST requests"""
                admin_control(req)
                if not id_.isdigit() or int(id_) <= 0:
                    raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST',
        Severity: Minor
        Found in myems-api/core/energyflowdiagram.py - 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

        Severity
        Category
        Status
        Source
        Language