Showing 194 of 194 total issues
Function initializeDropdownMenus
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
initializeDropdownMenus( menu ) {
const options = this.options;
let parentLinks;
Function bind
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Search.prototype.bind = function (decorated, container, $container) {
var self = this;
var resultsId = container.id + '-results';
decorated.call(this, container, $container);
Method get_social_links_icons
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_social_links_icons() {
if ( is_array( $this->social_links_icons ) ) {
return $this->social_links_icons;
}
Method handle_sticky_elements
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function handle_sticky_elements() {
// Skip for now since it is neither possible to set state nor animate position style based on position observer.
if ( ! $this->is_amp() || true ) {
return;
Function Select2
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Select2 = function ($element, options) {
if ($element.data('select2') != null) {
$element.data('select2').destroy();
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function register_customize_preview_js( $assets ) {
$assets->register_asset( new Super_Awesome_Theme_Script(
'super-awesome-theme-sidebar-customize-preview',
get_theme_file_uri( '/assets/dist/js/sidebar.customize-preview.js' ),
array(
- Read upRead up
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 116.
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
protected function register_customize_preview_js( $assets ) {
$assets->register_asset( new Super_Awesome_Theme_Script(
'super-awesome-theme-navbar-customize-preview',
get_theme_file_uri( '/assets/dist/js/navbar.customize-preview.js' ),
array(
- Read upRead up
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 116.
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 register_settings
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function register_settings() {
$settings = $this->get_dependency( 'settings' );
$this->attachment_metadata = new Super_Awesome_Theme_Attachment_Metadata( $settings );
$boolean_settings = array();
- 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 14 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( $id, array $args = array() ) {
$this->id = (string) $id;
$defaults = $this->get_defaults();
foreach ( $defaults as $prop => $default_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 bind
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
BaseSelection.prototype.bind = function (container, $container) {
var self = this;
var id = container.id + '-container';
var resultsId = container.id + '-results';
Method register_customize_controls_js
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function register_customize_controls_js( $assets ) {
$data = array(
'postTypes' => array(),
);
Function query
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Tags.prototype.query = function (decorated, params, callback) {
var self = this;
this._removeOldTags();
Method fetch_families
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function fetch_families() {
$filename = get_theme_file_path( 'assets/resources/google-webfonts.json' );
if ( ! file_exists( $filename ) ) {
return array();
}
Method print_base_font_style_general
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function print_base_font_style_general() {
$base_font = $this->get( 'base_font' );
$heading_font = $this->get( 'heading_font' );
if ( ! empty( $base_font['family_stack'] ) ) {
Identical blocks of code found in 2 locations. Consider refactoring. Open
<?php if ( ! is_singular( get_post_type() ) && ! post_password_required() && post_type_supports( get_post_type(), 'comments' ) && comments_open() ) : ?>
<span class="comments-link">
<?php
comments_popup_link(
sprintf(
- Read upRead up
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 113.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
<?php if ( ! is_singular( get_post_type() ) && ! post_password_required() && post_type_supports( get_post_type(), 'comments' ) && comments_open() ) : ?>
<span class="comments-link">
<?php
comments_popup_link(
sprintf(
- Read upRead up
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 113.
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 add_field
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function add_field( $id, array $args = array() ) {
if ( ! isset( $args[ self::FIELD_ARG_TYPE ] ) ) {
$args[ self::FIELD_ARG_TYPE ] = self::FIELD_TYPE_TEXT;
}
Function __call
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function __call( $method, $args ) {
switch ( $method ) {
case 'register_settings':
case 'register_customize_partials':
case 'register_customize_controls_js':
- 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 default_sanitize_callback
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function default_sanitize_callback( $value, $args ) {
switch ( $args[ self::FIELD_ARG_TYPE ] ) {
case self::FIELD_TYPE_NUMBER:
if ( isset( $args[ self::FIELD_ARG_INPUT_ATTRS ]['step'] ) && is_int( $args[ self::FIELD_ARG_INPUT_ATTRS ]['step'] ) ) {
$value = (int) $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 Decorate
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Utils.Decorate = function (SuperClass, DecoratorClass) {
var decoratedMethods = getMethods(DecoratorClass);
var superMethods = getMethods(SuperClass);
function DecoratedClass () {