Showing 55 of 55 total issues
Function add_commas_to_list
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function add_commas_to_list( $list, $suffix = false ) {
// We want a string, so let's convert it to one with an Oxford Comma
$string = '';
$count = 1;
foreach ( $list as $unit => $value ) :
- 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 add_header
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function add_header( $header ) {
// Check the variable. We expect string, but let's be sure.
if ( is_string( $header ) ) {
// Since it's a string, just push it into the headers array.
array_push( $this->headers, $header );
- 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 create_request
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function create_request( $url, $options, $cache_ttl, $cache_bin, $type ) {
if ( $cache_ttl > 0 ) {
// Create an object with caching on
$request = new Alphred\Request( $url, [ 'cache' => true,
Method write_item
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function write_item( $item ) {
// The information we need is stored in the sub variable, so let's just get that
$item = $item->data;
// These go in the 'item' part as an attribute
$attributes = [ 'uid', 'arg', 'autocomplete' ];
Function seconds_to_human_time
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function seconds_to_human_time( $seconds, $words = false, $type = 'string' ) {
$data = [];
$legend = self::$legend_english;
// Start with the greatest values and whittle down until we're left with seconds
- 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 print_section
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private static function print_section( $section ) {
$contents = '';
foreach( $section as $key => $value ) :
if ( is_array( $value ) ) {
foreach( $value as $v ) :
- 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 call_security
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private static function call_security( $action, $service, $account, $args ) {
if ( ! in_array( $action, [ 'add-generic-password', 'delete-generic-password', 'find-generic-password' ] ) ) {
throw new InvalidSecurityAction( "{$action} is not valid.", 4 );
// So, if, for some reason, the thing is caught, we can't really go on. So we'll exit anyway.
- 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 notify
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function notify( $options ) {
if ( is_string( $options ) ) {
exec( "osascript -e 'display notification \"{$options}\"'" );
return true;
}
- 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 write_ini
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function write_ini( $array, $file ) {
// Collapse the arrays into writeable sections
$sections = self::collapse_sections( $array );
// Separate out the things that need to be in the global space from the things
// that need to be in sectioned spaces
- 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 notify
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function notify( $options ) {
if ( is_string( $options ) ) {
exec( "osascript -e 'display notification \"{$options}\"'" );
return true;
}
Method write_ini
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function write_ini( $array, $file ) {
// Collapse the arrays into writeable sections
$sections = self::collapse_sections( $array );
// Separate out the things that need to be in the global space from the things
// that need to be in sectioned spaces
Function download
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function download( $url, $options = false, $cache_ttl = 0, $cache_bin = true, $destination = false ) {
$request = $this->create_request( $url, $options, $cache_ttl, $cache_bin, 'get' );
$request->execute();
// If a destination path has been set, then rename the cache file to the destination path after downloading it
- 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 set_buttons
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function set_buttons( $buttons, $default = '' ) {
if ( empty( $buttons ) ) {
// One could wonder why you're trying to give us an empty set of buttons. Give me an array, please.
// Or a string. Just something. Give me something.
return false;
- 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 title_case
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function title_case( $string ) {
// This needs to be improved upon. Basically, it needs to account for sentence ending punctuation.
// Words that are not capitalized. Well, articles, conjunctions, and prepositions.
$lower = [
'the','a','an','and','but','or','for','nor','aboard','about','above','across','after','against','along',
- 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 set_caches
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function set_caches( $options ) {
if ( ! isset( $options['cache_bin' ] ) ) {
// exit early if no cache bin is set
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 __construct
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( $engine = 'json' ) {
if ( ! file_exists( 'i18n' ) || ! is_dir( 'i18n' ) ) { return false; }
// This is internal, for testing. If the "ALPHRED_TESTING" flag is set,
// then we'll pretend that our language is French rather than the system
// default (for me: English). Consider this testing code.
- 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 read_ini
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function read_ini( $file, $exception = true ) {
if ( ! file_exists( $file ) ) {
if ( $exception ) {
throw new FileDoesNotExist( "File `{$file}` not found." );
} else {
- 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 create_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function create_request( $url, $options, $cache_ttl, $cache_bin, $type ) {
Method download
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function download( $url, $options = false, $cache_ttl = 0, $cache_bin = true, $destination = false ) {
Function create_dialog
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function create_dialog() {
// The script starts with this....
$this->script = "display dialog \"{$this->text}\"";
- 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"