Showing 370 of 370 total issues

Alerts_REST has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class Alerts_REST extends Models_REST {
    const SLOG_TYPE = SLog::T_ALERT;

    public static $MODEL = 'Alert';
    public static $CREATABLE = [];
Severity: Minor
Found in phplib/REST/Alerts.php - About 2 hrs to fix

    Method GET has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function GET(array $get) {
            $data = [];
            $meta = new DBMeta;
            $cfg = new DBConfig;
            $client = new ESClient;
    Severity: Major
    Found in phplib/REST/Dashboard.php - About 2 hrs to fix

      Function offsetSet has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public function offsetSet($key, $value) {
              $schema = static::getSchema();
              if(array_key_exists($key, $this->obj)) {
                  switch($schema[$key][0]) {
                      case static::T_BOOL:
      Severity: Minor
      Found in phplib/Model.php - About 2 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 _execute has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function _execute($date, $constructed_qdata) {
              // If our last_success_date is within 10 seconds of the start time, use that
              // as the start time.
              $from = $date - ($this->obj['range'] * 60);
              if(abs($this->obj['last_success_date'] - $from) < 10) {
      Severity: Minor
      Found in phplib/Search/ECL.php - About 2 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

      Method query has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function query($query, $fields=null, $from=null, $to=null, $scroll=false, $offset=null, $count=null) {
              $client = self::getClient();
      
              $filter = [];
              $conds = [];
      Severity: Major
      Found in phplib/ESClient.php - About 2 hrs to fix

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

                    model.getLink({
                        async: false,
                        success: this.cbRendered(function(data) {
                            if(data.link !== null) {
                                window.open(data.link, '_blank');
        Severity: Major
        Found in htdocs/assets/js/views/alerts/alertgroup.js and 1 other location - About 2 hrs to fix
        htdocs/assets/js/views/alerts/actions.js on lines 323..332

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

        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

                    model.getLink({
                        async: false,
                        success: this.cbRendered(function(data) {
                            if(data.link !== null) {
                                window.open(data.link, '_blank');
        Severity: Major
        Found in htdocs/assets/js/views/alerts/actions.js and 1 other location - About 2 hrs to fix
        htdocs/assets/js/views/alerts/alertgroup.js on lines 471..480

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

        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 _render has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                _render: function() {
                    this.groups = [];
        
                    if(this.settings.count > 0) {
                        // Always allow these.
        Severity: Major
        Found in htdocs/assets/js/views/alerts/actions.js - About 2 hrs to fix

          Model has 23 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Model implements \JsonSerializable, \ArrayAccess {
              // Field types
              /** Boolean field type. */
              const T_BOOL = 0;
              /** Numeric (int/float) field type. */
          Severity: Minor
          Found in phplib/Model.php - About 2 hrs to fix

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

                    unresolve: function(alerts) {
                        var view = new ActionModalView(this.App, {action: 'unresolve'});
                        this.App.setModal(view);
                        this.listenTo(view, 'action', function(data) {
                            this.setAlertState(alerts, data.note, 0);
            Severity: Major
            Found in htdocs/assets/js/views/alerts/actions.js and 1 other location - About 2 hrs to fix
            htdocs/assets/js/views/alerts/actions.js on lines 264..270

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

            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

                    escalate: function(alerts) {
                        var view = new ActionModalView(this.App, {action: 'escalate'});
                        this.App.setModal(view);
                        this.listenTo(view, 'action', function(data) {
                            this.setAlertEscalation(alerts, data.note, true);
            Severity: Major
            Found in htdocs/assets/js/views/alerts/actions.js and 1 other location - About 2 hrs to fix
            htdocs/assets/js/views/alerts/actions.js on lines 229..235

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

            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

                    acknowledge: function(alerts) {
                        var view = new ActionModalView(this.App, {action: 'acknowledge'});
                        this.App.setModal(view);
                        this.listenTo(view, 'action', function(data) {
                            this.setAlertState(alerts, data.note, 1);
            Severity: Major
            Found in htdocs/assets/js/views/alerts/actions.js and 1 other location - About 2 hrs to fix
            htdocs/assets/js/views/alerts/actions.js on lines 271..277

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

            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

                    deescalate: function(alerts) {
                        var view = new ActionModalView(this.App, {action: 'deescalate'});
                        this.App.setModal(view);
                        this.listenTo(view, 'action', function(data) {
                            this.setAlertEscalation(alerts, data.note, false);
            Severity: Major
            Found in htdocs/assets/js/views/alerts/actions.js and 1 other location - About 2 hrs to fix
            htdocs/assets/js/views/alerts/actions.js on lines 222..228

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

            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 _render has 60 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    _render: function() {
                        var model_data = this.model.toJSON();
                        var desc_parts = [];
            
                        var alert = this.App.Data.Alerts.get(this.model.get('alert_id'));
            Severity: Major
            Found in htdocs/assets/js/views/alerts/alert.js - About 2 hrs to fix

              Method run has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function run() {
                      switch($this->obj['target_id']) {
                      case static::I_HOURLY:
                          $type = Search::NT_HOURLY;
                          $range = 1 * 60 * 60;
              Severity: Major
              Found in phplib/Job/Rollup.php - About 2 hrs to fix

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

                        processCustomTest: function() {
                            var modal = new ExecutionConfigModalView(this.App);
                            this.App.setModal(modal);
                            this.listenTo(modal, 'run', $.proxy(function(data) {
                                this.processPreview(false, data);
                Severity: Major
                Found in htdocs/assets/js/views/searches/search.js and 1 other location - About 2 hrs to fix
                htdocs/assets/js/views/searches/search.js on lines 712..718

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

                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

                        processCustomExecute: function() {
                            var modal = new ExecutionConfigModalView(this.App);
                            this.App.setModal(modal);
                            this.listenTo(modal, 'run', $.proxy(function(data) {
                                this.processPreview(true, data);
                Severity: Major
                Found in htdocs/assets/js/views/searches/search.js and 1 other location - About 2 hrs to fix
                htdocs/assets/js/views/searches/search.js on lines 702..708

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

                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

                Search has 22 functions (exceeds 20 allowed). Consider refactoring.
                Open

                abstract class Search extends TypeModel {
                    public static $TYPES = [
                        Null_Search::class,
                        ES_Search::class,
                        ECL_Search::class,
                Severity: Minor
                Found in phplib/Search.php - About 2 hrs to fix

                  Method setAlertFields has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function setAlertFields($data, $fields, $alog_action, $slog_action, $a=0, $b=0) {
                          if(!$this->allowUpdate()) {
                              throw new ForbiddenException;
                          }
                  
                  
                  Severity: Major
                  Found in phplib/REST/Alerts.php - About 2 hrs to fix

                    Function _render has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            _render: function() {
                                this.App.setTitle('Alert: ' + this.model.get('id'));
                                this.registerView(new AlertNavbarView(this.App, {model: this.model}), true);
                    
                                this.App.registerSelectableGroup(this);
                    Severity: Major
                    Found in htdocs/assets/js/views/alerts/alert.js - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language