Showing 644 of 644 total issues
Function add_sub_fields
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function add_sub_fields( $args ) {
$args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global';
$defaults = isset( $args['default'] ) ? $args['default'] : [];
- Read upRead up
- Create a ticketCreate a ticket
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_settings
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
final function add_settings( $args = [] ) {
// Get the classname we'll be using to create our setting(s).
$classname = false;
if ( isset( $args['option_type'] ) && array_key_exists( $args['option_type'], $this->setting_types ) ) {
- Read upRead up
- Create a ticketCreate a ticket
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (2 === val.length) {
if (!val.includes("#") && !val.includes("rg") && !val.includes("hs")) {
val = "#" + val;
}
} else if (3 === val.length || 6 === val.length) {
- Read upRead up
- Create a ticketCreate a ticket
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 60.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function runHooks
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function runHooks(hookName) {
if (!hooks[hookName]) {
hooks[hookName] = {
handlers: [],
runs: 0
- Create a ticketCreate a ticket
Function postfix
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function postfix( expression ) {
var terms = [],
stack = [],
match, operator, term, element;
- Create a ticketCreate a ticket
Function updateClassName
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
DomHelper.prototype.updateClassName = function (e, opt_add, opt_remove) {
var add = opt_add || [],
remove = opt_remove || [];
var classes = e.className.split(/\s+/);
- Create a ticketCreate a ticket
Method init_filesystem
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function init_filesystem() {
$credentials = [];
if ( ! defined( 'FS_METHOD' ) ) {
define( 'FS_METHOD', 'direct' );
- Create a ticketCreate a ticket
Method default_control_types
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function default_control_types( $control_types = [] ) {
$this->control_types = [
'kirki-composite' => '\Kirki\Control\Composite',
'checkbox' => '\Kirki\Control\Checkbox',
'kirki-color' => '\Kirki\Control\ReactColorful',
- Create a ticketCreate a ticket
Function exports
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (TYPE, $create) {
var IS_MAP = TYPE == 1;
var IS_FILTER = TYPE == 2;
var IS_SOME = TYPE == 3;
var IS_EVERY = TYPE == 4;
- Create a ticketCreate a ticket
Method getLoader
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
- Create a ticketCreate a ticket
Function run
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
var run = function (reaction) {
var handler = ok ? reaction.ok : reaction.fail;
var resolve = reaction.resolve;
var reject = reaction.reject;
var domain = reaction.domain;
- Create a ticketCreate a ticket
Function parse
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
FontApiParser.prototype.parse = function() {
var length = this.fontFamilies_.length;
for (var i = 0; i < length; i++) {
var elements = this.fontFamilies_[i].split(":");
- Create a ticketCreate a ticket
Method field_add_control_args
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function field_add_control_args( $args ) {
if ( isset( $args['active_callback'] ) ) {
if ( is_array( $args['active_callback'] ) ) {
if ( ! is_callable( $args['active_callback'] ) ) {
- Create a ticketCreate a ticket
Function getSubstitution
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
var tailPos = position + matched.length;
var m = captures.length;
var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
if (namedCaptures !== undefined) {
- Create a ticketCreate a ticket
Method addPsr4
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
- Create a ticketCreate a ticket
Function kirkiTooltipAdd
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function kirkiTooltipAdd( control ) {
_.each( kirkiTooltips, function ( tooltip ) {
if ( tooltip.id !== control.id ) {
return;
}
- Create a ticketCreate a ticket
Method add
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Open
control.container.on( 'click keypress', '.repeater-field-image .upload-button,.repeater-field-cropped_image .upload-button,.repeater-field-upload .upload-button', function( e ) {
e.preventDefault();
control.$thisButton = jQuery( this );
control.openFrame( e );
} );
- Read upRead up
- Create a ticketCreate a ticket
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 59.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
control.container.on( 'click keypress', '.repeater-field-image .remove-button,.repeater-field-cropped_image .remove-button', function( e ) {
e.preventDefault();
control.$thisButton = jQuery( this );
control.removeImage( e );
} );
- Read upRead up
- Create a ticketCreate a ticket
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 59.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method content_template
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function content_template() {
?>
<div class="kirki-switch-control kirki-{{ data.checkboxType }}">
<# if ( data.label || data.description ) { #>
- Create a ticketCreate a ticket