Showing 194 of 194 total issues
Function bind
has 81 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);
Function _registerEvents
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
Select2.prototype._registerEvents = function () {
var self = this;
this.on('open', function () {
self.$container.addClass('select2-container--open');
Function add_control
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function add_control( $setting_id, $control_args = array() ) {
if ( ! isset( $this->wp_customize ) ) {
throw Super_Awesome_Theme_Customizer_Not_Loaded_Exception::from_method_and_id( __METHOD__, $setting_id );
}
- 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 register_customize_partials
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function register_customize_partials( $customizer ) {
$customizer->add_panel( 'content_types', array(
Super_Awesome_Theme_Customize_Panel::PROP_TITLE => __( 'Content Types', 'super-awesome-theme' ),
Super_Awesome_Theme_Customize_Panel::PROP_PRIORITY => 140,
) );
Method print_base_color_style_button
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function print_base_color_style_button() {
$button_text_color = $this->get( 'button_text_color' );
$button_background_color = $this->get( 'button_background_color' );
$button_background_focus_color = $this->util()->darken_color( $button_background_color, 25 );
$button_primary_text_color = $this->get( 'button_primary_text_color' );
Function handler
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handler(event) {
var orgEvent = event || window.event,
args = slice.call(arguments, 1),
delta = 0,
deltaX = 0,
Method print_color_style_css
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function print_color_style_css() {
/**
* Fires when the custom color styles are printed inside a style tag.
*
Function fromElement
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
Options.prototype.fromElement = function ($e) {
var excludedData = ['select2'];
if (this.options.multiple == null) {
this.options.multiple = $e.prop('multiple');
Function normalize
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function normalize(name, baseName) {
var nameParts, nameSegment, mapValue, foundMap, lastIndex,
foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
baseParts = baseName && baseName.split("/"),
map = config.map,
File class-widget.php
has 275 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Super_Awesome_Theme_Widget class
*
* @package Super_Awesome_Theme
Function register_customize_partials
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
protected function register_customize_partials( $customizer ) {
$customizer->add_panel( 'content_types', array(
Super_Awesome_Theme_Customize_Panel::PROP_TITLE => __( 'Content Types', 'super-awesome-theme' ),
Super_Awesome_Theme_Customize_Panel::PROP_PRIORITY => 140,
) );
- 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 render_form_field
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
protected function render_form_field( $id, $args, $value ) {
$control_id = $this->get_field_id( $id );
$control_name = $this->get_field_name( $id );
$type = $args[ self::FIELD_ARG_TYPE ];
$title = $args[ self::FIELD_ARG_TITLE ];
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
<?php
/**
* The template for displaying search results pages
*
* @package Super_Awesome_Theme
- 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 132.
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
/**
* The template for displaying archive pages
*
* @package Super_Awesome_Theme
- 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 132.
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 fetch_families
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function fetch_families() {
$filename = get_theme_file_path( 'assets/resources/google-webfonts.json' );
if ( ! file_exists( $filename ) ) {
return 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
Method calculate_content_image_sizes
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function calculate_content_image_sizes( $sizes, $size ) {
$settings = $this->get_dependency( 'settings' );
$sidebar = $this->get_dependency( 'sidebar' );
$rem = 16;
Super_Awesome_Theme_Colors
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
final class Super_Awesome_Theme_Colors extends Super_Awesome_Theme_Theme_Component_Base {
/**
* Utility methods instance.
*
Method super_awesome_theme_wpsi_render_styles
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function super_awesome_theme_wpsi_render_styles( $id, $colors ) {
?>
<style id="<?php echo esc_attr( $id ); ?>" type="text/css">
<?php if ( ! empty( $colors['primary'] ) ) : ?>
a,
Function reset
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
Defaults.prototype.reset = function () {
function stripDiacritics (text) {
// Used 'uni range + named function' from http://jsperf.com/diacritics/18
function match(a) {
return DIACRITICS[a] || a;
Function ensure_inline_widgets_whitelist
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
protected function ensure_inline_widgets_whitelist( $sidebars_widgets ) {
foreach ( $this->inline_widget_areas as $widget_area_id ) {
if ( empty( $sidebars_widgets[ $widget_area_id ] ) ) {
continue;
}
- 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"