librenms/librenms

View on GitHub

Showing 1,511 of 31,793 total issues

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

function backupRRDFile($rrdfile)
{
    global $using_cacti, $tempdir, $seed, $html;

    if ($using_cacti) {
Severity: Minor
Found in scripts/removespikes.php - 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 updated has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function updated(Device $device): void
    {
        // handle device dependency updates
        if ($device->isDirty('max_depth')) {
            $device->children->each->updateMaxDepth();
Severity: Minor
Found in app/Observers/DeviceObserver.php - 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 setClass has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function setClass($class = null, $default = 'system')
    {
        if ($class) {
            $this->mempool_class = $class;

Severity: Minor
Found in app/Models/Mempool.php - 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 updateMaxDepth has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function updateMaxDepth($exclude = null)
    {
        // optimize for memory instead of time
        $query = $this->parents()->getQuery();
        if (! is_null($exclude)) {
Severity: Minor
Found in app/Models/Device.php - 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 inferEncoding has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function inferEncoding(?string $string): ?string
    {
        if (empty($string) || preg_match('//u', $string) || ! function_exists('iconv')) {
            return $string;
        }
Severity: Minor
Found in LibreNMS/Util/StringHelpers.php - 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 parseInput has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseInput()
    {
        $check = $this->argument('check');
        if (! in_array($check, ['all', 'lint', 'style', 'unit', 'web', 'ci'])) {
            $this->error("Invalid check: $check");
Severity: Minor
Found in app/Console/Commands/DevCheckCommand.php - 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 appStateIcon has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function appStateIcon($app_state)
    {
        switch ($app_state) {
            case 'OK':
                $icon = '';
Severity: Minor
Found in LibreNMS/Util/Html.php - 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 printReport has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function printReport(array $headers, array|Collection $rows): void
    {
        $output = $this->option('output');

        if ($output == 'csv') {
Severity: Minor
Found in app/Console/Commands/ReportDevices.php - 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 lookupCoordinates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function lookupCoordinates($hostname = null)
    {
        if ($this->location && $this->parseCoordinates()) {
            return true;
        }
Severity: Minor
Found in app/Models/Location.php - 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 handle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function handle()
    {
        $setting = $this->argument('setting');

        // load os definition if requested, and remove special definition_loaded key
Severity: Minor
Found in app/Console/Commands/GetConfigCommand.php - 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 scopeWhereDeviceSpec has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function scopeWhereDeviceSpec(Builder $query, ?string $deviceSpec): Builder
    {
        if (empty($deviceSpec)) {
            return $query;
        } elseif ($deviceSpec == 'all') {
Severity: Minor
Found in app/Models/Device.php - 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 handle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function handle(\SocialiteProviders\Manager\SocialiteWasCalled $event): void
    {
        foreach (Config::get('auth.socialite.configs', []) as $provider => $config) {
            // Treat not set as "disabled"
            if (! isset($config['listener'])) {
Severity: Minor
Found in app/Listeners/SocialiteWasCalledListener.php - 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 discoverType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function discoverType(OS $os, $type)
    {
        $typeInterface = static::getDiscoveryInterface($type);
        if (! interface_exists($typeInterface)) {
            echo "ERROR: Discovery Interface doesn't exist! $typeInterface\n";
Severity: Minor
Found in LibreNMS/Device/Sensor.php - 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 list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function list()
    {
        $services = [];
        if (is_dir(Config::get('nagios_plugins'))) {
            foreach (scandir(Config::get('nagios_plugins')) as $file) {
Severity: Minor
Found in LibreNMS/Services.php - 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 portLink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function portLink($port, $text = null, $type = null, $overlib = true, $single_graph = false)
    {
        if ($port === null) {
            return $text;
        }
Severity: Minor
Found in LibreNMS/Util/Url.php - 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 embedGraphs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static function embedGraphs(PHPMailer $mail, bool $html = false): void
    {
        $body = $mail->Body;

        // search for generated graphs
Severity: Minor
Found in LibreNMS/Util/Mail.php - 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 parseGroup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseGroup($rule, $expand = false, $wrap = true)
    {
        $group_rules = [];

        foreach ($rule['rules'] as $group_rule) {
Severity: Minor
Found in LibreNMS/Alerting/QueryBuilderParser.php - 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 _reload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function _reload($params)
    {
        if ($this->user['user']->can('irc.reload')) {
            if ($params == 'external') {
                $this->respond('Reloading external scripts.');
Severity: Minor
Found in LibreNMS/IRCBot.php - 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 poll has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function poll(OS $os, DataStorageInterface $datastore): void
    {
        if ($os instanceof SlaPolling) {
            // Gather our SLA's from the DB.
            $slas = $os->getDevice()->slas()
Severity: Minor
Found in LibreNMS/Modules/Slas.php - 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 generateGlue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function generateGlue($target = 'devices')
    {
        $tables = $this->getTables();  // get all tables in query

        // always add the anchor to the target table
Severity: Minor
Found in LibreNMS/Alerting/QueryBuilderParser.php - 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