Showing 370 of 370 total issues

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

    public function sendAlerts($data) {
        if(!$this->allowUpdate()) {
            throw new ForbiddenException;
        }

Severity: Minor
Found in phplib/REST/Alerts.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

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

    private function processFilters(array $alerts, array $filters, $date) {
        $errors = [];

        foreach($filters as $filter) {
            $new_alerts = [];
Severity: Minor
Found in phplib/Job/Search.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

Avoid deeply nested control flow statements.
Open

                            if(vtok.length === 0) {
                                throw new ParseException('Empty group: "' + ktok + '"');
                            }
Severity: Major
Found in htdocs/assets/js/queryparser.js - About 45 mins to fix

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

        private function setAlertFields($data, $fields, $alog_action, $slog_action, $a=0, $b=0) {
    Severity: Minor
    Found in phplib/REST/Alerts.php - About 45 mins to fix

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

          protected function constructQuery() {
              $query = Util::get($this->obj['query_data'], 'query', '');
              $range = Util::get($this->obj['query_data'], 'range', 10);
              $type = Util::get($this->obj['query_data'], 'type', '');
      
      
      Severity: Minor
      Found in phplib/Search/ThreatExchange.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

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

          public static function getEmails($type, $entry, $update=true, $all=false) {
              $emails = [];
              switch($type) {
                  case self::T_USER:
                      $user = UserFinder::getById($entry);
      Severity: Minor
      Found in phplib/Assignee.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

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

          public static function getClient($config_name='alerts', $index=false) {
              $escfg = Config::get('elasticsearch')[$config_name];
              $cb = \Elasticsearch\ClientBuilder::create();
              if($index && count($escfg['index_hosts']) > 0) {
                  $cb->setHosts($escfg['index_hosts']);
      Severity: Minor
      Found in phplib/ESClient.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 sendAlertActionEmail has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public static function sendAlertActionEmail($to, $action, $searches, $alerts, $content_only=false, $debug_data=[]) {
      Severity: Minor
      Found in phplib/Notification.php - About 45 mins to fix

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

            private function processSearches($date, $search_health, $backfill) {
                foreach(SearchFinder::getByQuery(['enabled' => 1]) as $search) {
                    // If the search doesn't need to run OR
                    // the search type is failing and isn't time based
                    // skip it!
        Severity: Minor
        Found in phplib/Scheduler.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

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

            public static function sendAlertEmail($to, $search, $alerts, $content_only, $debug_data=[]) {
                $alertkeys = [];
                $long = false;
                foreach($alerts as $alert) {
                    if(count($alert['content']) >= 10) {
        Severity: Minor
        Found in phplib/Notification.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

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

                        this.registerView(
                            new FiltersListView(this.App, {collection: this.filters, model: this.model}),
                            true, this.$('#filter-list'), 'filters'
                        );
        Severity: Minor
        Found in htdocs/assets/js/views/searches/search.js and 1 other location - About 45 mins to fix
        htdocs/assets/js/views/searches/search.js on lines 550..553

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

        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

                        this.registerView(
                            new TargetsListView(this.App, {collection: this.targets, model: this.model}),
                            true, this.$('#target-list'), 'targets'
                        );
        Severity: Minor
        Found in htdocs/assets/js/views/searches/search.js and 1 other location - About 45 mins to fix
        htdocs/assets/js/views/searches/search.js on lines 546..549

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

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

            var ListsNavbarView = NavbarView.extend({
                title: 'Lists',
                sidelinks: [
                    {name: 'Create', icon: 'file', link: '/lists/new', action: 'create'}
                ]
        Severity: Major
        Found in htdocs/assets/js/views/lists/lists.js and 2 other locations - About 40 mins to fix
        htdocs/assets/js/views/groups/groups.js on lines 11..16
        htdocs/assets/js/views/users/users.js on lines 9..14

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

        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

            var TargetsListView = ElementsListView.extend({
                title: 'Targets',
                subClass: Target,
                subView: TargetView,
                editView: TargetEditModalView,
        Severity: Minor
        Found in htdocs/assets/js/views/searches/search.js and 1 other location - About 40 mins to fix
        htdocs/assets/js/views/searches/search.js on lines 439..446

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

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

            var GroupsNavbarView = NavbarView.extend({
                title: 'Groups',
                sidelinks: [
                    {name: 'Create', icon: 'file', link: '/groups/new', action: 'create'}
                ]
        Severity: Major
        Found in htdocs/assets/js/views/groups/groups.js and 2 other locations - About 40 mins to fix
        htdocs/assets/js/views/lists/lists.js on lines 11..16
        htdocs/assets/js/views/users/users.js on lines 9..14

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

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

            var UsersNavbarView = NavbarView.extend({
                title: 'Users',
                sidelinks: [
                    {name: 'Create', icon: 'file', link: '/users/new', action: 'create'}
                ]
        Severity: Major
        Found in htdocs/assets/js/views/users/users.js and 2 other locations - About 40 mins to fix
        htdocs/assets/js/views/groups/groups.js on lines 11..16
        htdocs/assets/js/views/lists/lists.js on lines 11..16

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

        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

            var FiltersListView = ElementsListView.extend({
                title: 'Filters',
                subClass: Filter,
                subView: FilterView,
                editView: FilterEditModalView,
        Severity: Minor
        Found in htdocs/assets/js/views/searches/search.js and 1 other location - About 40 mins to fix
        htdocs/assets/js/views/searches/search.js on lines 448..455

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

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

                    this.App.setTitle('Search: ' + (this.model.isNew() ? 'New':this.model.get('id')));
        Severity: Major
        Found in htdocs/assets/js/views/searches/search.js and 4 other locations - About 40 mins to fix
        htdocs/assets/js/views/groups/group.js on lines 135..135
        htdocs/assets/js/views/lists/list.js on lines 53..53
        htdocs/assets/js/views/reports/report.js on lines 119..119
        htdocs/assets/js/views/users/user.js on lines 34..34

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

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

                    this.App.setTitle('List: ' + (this.model.isNew() ? 'New':this.model.get('id')));
        Severity: Major
        Found in htdocs/assets/js/views/lists/list.js and 4 other locations - About 40 mins to fix
        htdocs/assets/js/views/groups/group.js on lines 135..135
        htdocs/assets/js/views/reports/report.js on lines 119..119
        htdocs/assets/js/views/searches/search.js on lines 510..510
        htdocs/assets/js/views/users/user.js on lines 34..34

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

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

                    this.App.setTitle('Group: ' + (this.model.isNew() ? 'New':this.model.get('id')));
        Severity: Major
        Found in htdocs/assets/js/views/groups/group.js and 4 other locations - About 40 mins to fix
        htdocs/assets/js/views/lists/list.js on lines 53..53
        htdocs/assets/js/views/reports/report.js on lines 119..119
        htdocs/assets/js/views/searches/search.js on lines 510..510
        htdocs/assets/js/views/users/user.js on lines 34..34

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

        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

        Severity
        Category
        Status
        Source
        Language