File ESClient.php
has 456 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace FOO;
/**
Method getActiveAlertCounts
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getActiveAlertCounts() {
$client = self::getClient();
$filter = [
[
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 = [];
Method getAlertActivityCounts
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAlertActivityCounts($range, $search_id=0) {
$client = self::getClient();
$filter = [
[
Function getActiveAlertCounts
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function getActiveAlertCounts() {
$client = self::getClient();
$filter = [
[
- Read upRead up
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 bootstrap
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function bootstrap($query, $from=null, $to=null) {
$client = self::getClient();
$fields = ['escalated', 'assignee_type', 'assignee', 'search_id', 'state'];
$aggs = [];
Method initializeIndex
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function initializeIndex() {
// Create template.
if(!$this->client->indices()->existsTemplate(['name' => self::MAPPING_TEMPLATE])) {
$version = explode('.', $this->client->info()['version']['number'])[0];
$string_type = 'string';
Function query
has a Cognitive Complexity of 11 (exceeds 5 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 = [];
- Read upRead up
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 7 arguments (exceeds 4 allowed). Consider refactoring. Open
private function query($query, $fields=null, $from=null, $to=null, $scroll=false, $offset=null, $count=null) {
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']);
- Read upRead up
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 getAlerts
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function getAlerts($query, $from, $to, $offset, $count) {
Function send
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function send() {
if(count($this->list) == 0) {
return;
}
- Read upRead up
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 bootstrapRecurse
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function bootstrapRecurse($node, $data, $count, $fields) {
$ret = [];
if(array_key_exists('agg', $data)) {
$key = array_pop($fields);
- Read upRead up
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"