librenms/librenms

View on GitHub

Showing 1,514 of 31,573 total issues

Function check_service has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
Open

function check_service($command)
{
    // This array is used to test for valid UOM's to be used for graphing.
    // Valid values from: https://nagios-plugins.org/doc/guidelines.html#AEN200
    // Note: This array must be decend from 2 char to 1 char so that the search works correctly.
Severity: Minor
Found in includes/services.inc.php - About 1 day 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 alert_details has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
Open

function alert_details($details)
{
    if (is_string($details)) {
        $details = json_decode(gzuncompress($details), true);
    } elseif (! is_array($details)) {
Severity: Minor
Found in includes/html/functions.inc.php - About 1 day 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 common.php has 559 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*
 * LibreNMS - Common Functions
 *
 * Original Observium version by: Adam Armstrong, Tom Laermans
Severity: Major
Found in includes/common.php - About 1 day to fix

    Function runRules has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
    Open

        public function runRules($device_id)
        {
            //Check to see if under maintenance
            if (AlertUtil::isMaintenance($device_id) > 0) {
                echo "Under Maintenance, skipping alert rules check.\r\n";
    Severity: Minor
    Found in LibreNMS/Alert/AlertRules.php - About 1 day 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 ModuleTestHelper.php has 550 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * ModuleTester.php
     *
     * -Description-
    Severity: Major
    Found in LibreNMS/Util/ModuleTestHelper.php - About 1 day to fix

      File queuemanager.py has 549 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import logging
      import threading
      import traceback
      from queue import Empty
      from subprocess import CalledProcessError
      Severity: Major
      Found in LibreNMS/queuemanager.py - About 1 day to fix

        Function collectd_draw_rrd has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
        Open

        function collectd_draw_rrd($host, $plugin, $type, $pinst = null, $tinst = null, $opts = [])
        {
            $timespan_def = null;
            $timespans = Config::get('timespan');
            if (! isset($opts['timespan'])) {
        Severity: Minor
        Found in includes/html/collectd/functions.php - About 1 day 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 process_syslog has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
        Open

        function process_syslog($entry, $update)
        {
            global $dev_cache;
        
            foreach (Config::get('syslog_filter') as $bi) {
        Severity: Minor
        Found in includes/syslog.php - About 1 day 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 ResolveGlues has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
        Open

        function ResolveGlues($tables, $target, $x = 0, $hist = [], $last = [])
        {
            if (sizeof($tables) == 1 && $x != 0) {
                if (dbFetchCell('SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_NAME = ? && COLUMN_NAME = ?', [$tables[0], $target]) == 1) {
                    return array_merge($last, [$tables[0] . '.' . $target]);
        Severity: Minor
        Found in includes/common.php - About 1 day 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 printEntPhysical has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
        Open

        function printEntPhysical($device, $ent, $level, $class)
        {
            $ents = dbFetchRows('SELECT * FROM `entPhysical` WHERE device_id = ? AND entPhysicalContainedIn = ? ORDER BY entPhysicalContainedIn,entPhysicalIndex', [$device['device_id'], $ent]);
        
            foreach ($ents as $ent) {
        Severity: Minor
        Found in includes/html/pages/device/entphysical.inc.php - About 1 day 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 preCache has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function preCache(OS $os)
            {
                // Pre-cache data for later use
                $pre_cache = [];
                $device = $os->getDeviceArray();
        Severity: Minor
        Found in LibreNMS/Device/YamlDiscovery.php - About 1 day 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 snmp.inc.php has 500 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /*
         * LibreNMS - SNMP Functions
         *
         * Original Observium code by: Adam Armstrong, Tom Laermans
        Severity: Minor
        Found in includes/snmp.inc.php - About 1 day to fix

          File command_runner.py has 483 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          #! /usr/bin/env python
          #  -*- coding: utf-8 -*-
          #
          # This file is part of command_runner module
          
          
          Severity: Minor
          Found in LibreNMS/command_runner.py - About 7 hrs to fix

            Function get has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

                public function get(Request $request, CustomMap $map): JsonResponse
                {
                    $this->authorize('view', $map);
            
                    $edges = [];
            Severity: Minor
            Found in app/Http/Controllers/Maps/CustomMapDataController.php - About 7 hrs 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 discover has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function discover(OS $os, $class, $yaml_data)
                {
                    $pre_cache = $os->preCache();
                    $device = $os->getDeviceArray();
                    $items = [];
            Severity: Minor
            Found in LibreNMS/Device/YamlDiscovery.php - About 7 hrs 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 pollOS has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
            Open

                public function pollOS(DataStorageInterface $datastore): void
                {
                    // Polling the Wireless data TODO port to module
                    $apTable = snmpwalk_group($this->getDeviceArray(), 'hwWlanApName', 'HUAWEI-WLAN-AP-MIB', 2);
            
            
            Severity: Minor
            Found in LibreNMS/OS/Vrp.php - About 7 hrs 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 getData has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
            Open

                private function getData()
                {
                    if (($data = $this->read('irc')) !== false) {
                        $this->last_activity = time();
                        $this->data = $data;
            Severity: Minor
            Found in LibreNMS/IRCBot.php - About 7 hrs 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 Pmp.php has 456 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Pmp.php
             *
             * Cambium
            Severity: Minor
            Found in LibreNMS/OS/Pmp.php - About 6 hrs to fix

              Method configDefinition has 173 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function configDefinition($groups = null)
                  {
                      if ($groups === null || $groups === true) {
                          $groups = PollerGroup::list();
                      }
              Severity: Major
              Found in app/Models/PollerCluster.php - About 6 hrs to fix

                Function create_edit_bill has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
                Open

                function create_edit_bill(Illuminate\Http\Request $request)
                {
                    $data = json_decode($request->getContent(), true);
                    if (! $data) {
                        return api_error(500, 'Invalid JSON data');
                Severity: Minor
                Found in includes/html/api_functions.inc.php - About 6 hrs 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