bexiocom/prometheus_php

View on GitHub

Showing 22 of 22 total issues

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

<?php
/**
 * @file
 * Contains Bexio\PrometheusPHP\Metric\CounterCollection.
 */
Severity: Major
Found in src/Metric/CounterCollection.php and 1 other location - About 5 hrs to fix
src/Metric/GaugeCollection.php on lines 1..69

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

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

<?php
/**
 * @file
 * Contains Bexio\PrometheusPHP\Metric\GaugeCollection.
 */
Severity: Major
Found in src/Metric/GaugeCollection.php and 1 other location - About 5 hrs to fix
src/Metric/CounterCollection.php on lines 1..69

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

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 4 locations. Consider refactoring.
Open

<?php
/**
 * @file
 * Contains Bexio\PrometheusPHP\Action\Set.
 */
Severity: Major
Found in src/Action/Set.php and 3 other locations - About 3 hrs to fix
src/Action/Add.php on lines 1..60
src/Action/Observe.php on lines 1..61
src/Action/Subtract.php on lines 1..61

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

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 4 locations. Consider refactoring.
Open

<?php
/**
 * @file
 * Contains Bexio\PrometheusPHP\Action\Add.
 */
Severity: Major
Found in src/Action/Observe.php and 3 other locations - About 3 hrs to fix
src/Action/Add.php on lines 1..60
src/Action/Set.php on lines 1..60
src/Action/Subtract.php on lines 1..61

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

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 4 locations. Consider refactoring.
Open

<?php
/**
 * @file
 * Contains Bexio\PrometheusPHP\Action\Add.
 */
Severity: Major
Found in src/Action/Subtract.php and 3 other locations - About 3 hrs to fix
src/Action/Add.php on lines 1..60
src/Action/Observe.php on lines 1..61
src/Action/Set.php on lines 1..60

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

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 4 locations. Consider refactoring.
Open

<?php
/**
 * @file
 * Contains Bexio\PrometheusPHP\Action\Add.
 */
Severity: Major
Found in src/Action/Add.php and 3 other locations - About 3 hrs to fix
src/Action/Observe.php on lines 1..61
src/Action/Set.php on lines 1..60
src/Action/Subtract.php on lines 1..61

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

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

<?php
/**
 * @file
 * Contains Bexio\PrometheusPHP\Action\Add.
 */
Severity: Major
Found in src/Action/Increment.php and 1 other location - About 1 hr to fix
src/Action/Decrement.php on lines 1..52

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

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

<?php
/**
 * @file
 * Contains Bexio\PrometheusPHP\Action\Add.
 */
Severity: Major
Found in src/Action/Decrement.php and 1 other location - About 1 hr to fix
src/Action/Increment.php on lines 1..53

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

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

    public function set(Settable $metric, $value)
    {
        $this->openConnection();
        try {
            $this->redis->hSet($this->getMetricKey($metric), $this->getLabelsKey($metric), $value);
Severity: Major
Found in src/Storage/Redis.php and 1 other location - About 1 hr to fix
src/Storage/Redis.php on lines 111..119

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

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

    public function add(Addable $metric, $value)
    {
        $this->openConnection();
        try {
            $this->redis->hIncrByFloat($this->getMetricKey($metric), $this->getLabelsKey($metric), $value);
Severity: Major
Found in src/Storage/Redis.php and 1 other location - About 1 hr to fix
src/Storage/Redis.php on lines 98..106

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

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

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

    public static function createFromValues($name, $help, $namespace = null, $subsystem = null, array $labels = array())
    {
        $options = new CounterOptions($name, $help, $namespace, $subsystem, $labels);

        return new Counter($options);
Severity: Major
Found in src/Metric/Counter.php and 1 other location - About 1 hr to fix
src/Metric/Gauge.php on lines 40..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 73.

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

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

    public static function createFromValues($name, $help, $namespace = null, $subsystem = null, array $labels = array())
    {
        $options = new GaugeOptions($name, $help, $namespace, $subsystem, $labels);

        return new Gauge($options);
Severity: Major
Found in src/Metric/Gauge.php and 1 other location - About 1 hr to fix
src/Metric/Counter.php on lines 35..40

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

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

Method collectSingleSamples has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function collectSingleSamples(MetricType $metric)
    {
        $options = $metric->getOptions();
        $buckets = $options instanceof HistogramOptions
            ? array_merge($options->getBuckets(), array('+Inf'))
Severity: Minor
Found in src/Storage/ArrayStorage.php - About 1 hr to fix

    Method createFromValues has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            $name,
            $help,
            array $labelNames,
            array $buckets,
            $namespace = null,
    Severity: Major
    Found in src/Metric/HistogramCollection.php - About 50 mins to fix

      Method createFromValues has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              $name,
              $help,
              array $buckets = null,
              $namespace = null,
              $subsystem = null,
      Severity: Minor
      Found in src/Metric/Histogram.php - About 45 mins to fix

        Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                $name,
                $help,
                array $buckets = null,
                $namespace = null,
                $subsystem = null,
        Severity: Minor
        Found in src/Metric/HistogramOptions.php - About 45 mins to fix

          Function getLabelsKey has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function getLabelsKey(MetricType $metric, $value = null)
              {
                  $options = $metric->getOptions();
                  $labels = $options->getLabels();
                  if ($options instanceof HistogramOptions && null !== $value) {
          Severity: Minor
          Found in src/Storage/ArrayStorage.php - 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

          Method createFromValues has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  $name,
                  $help,
                  array $labelNames,
                  $namespace = null,
                  $subsystem = null,
          Severity: Minor
          Found in src/Metric/GaugeCollection.php - About 45 mins to fix

            Method createFromValues has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    $name,
                    $help,
                    array $labelNames,
                    $namespace = null,
                    $subsystem = null,
            Severity: Minor
            Found in src/Metric/CounterCollection.php - About 45 mins to fix

              Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function __construct($name, $help, $namespace = null, $subsystem = null, array $constantLabels = array())
              Severity: Minor
              Found in src/Options.php - About 35 mins to fix
                Severity
                Category
                Status
                Source
                Language