File class-content-types.php
has 330 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Super_Awesome_Theme_Content_Types class
*
* @package Super_Awesome_Theme
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,
) );
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
Method __call
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __call( $method, $args ) {
switch ( $method ) {
case 'register_settings':
case 'register_customize_partials':
case 'register_customize_controls_js':
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
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 __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
Method register_settings
has 32 lines of code (exceeds 25 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();
Method detect_post_type
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function detect_post_type() {
switch ( true ) {
case is_front_page():
if ( is_home() ) {
return 'post';
Function detect_post_type
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function detect_post_type() {
switch ( true ) {
case is_front_page():
if ( is_home() ) {
return 'post';
- 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 register_customize_controls_js
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function register_customize_controls_js( $assets ) {
$data = array(
'postTypes' => 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
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return '';
Avoid too many return
statements within this method. Open
return reset( $taxonomy->object_type );
Avoid too many return
statements within this method. Open
return $post_types;
Avoid too many return
statements within this method. Open
return reset( $post_types );
Avoid too many return
statements within this method. Open
return;
Similar blocks of code found in 2 locations. Consider refactoring. Open
$customizer->add_partial( $post_type->name . '_archive_content', array(
Super_Awesome_Theme_Customize_Partial::PROP_SETTINGS => array( $post_type->name . '_use_excerpt' ),
Super_Awesome_Theme_Customize_Partial::PROP_SELECTOR => '.type-' . $post_type->name . '.archive-view .entry-content',
Super_Awesome_Theme_Customize_Partial::PROP_RENDER_CALLBACK => array( $this, 'partial_entry_content' ),
Super_Awesome_Theme_Customize_Partial::PROP_CONTAINER_INCLUSIVE => true,
- 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 100.
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
$customizer->add_partial( $post_type->name . '_entry_authorbox', array(
Super_Awesome_Theme_Customize_Partial::PROP_SETTINGS => array( $post_type->name . '_show_authorbox' ),
Super_Awesome_Theme_Customize_Partial::PROP_SELECTOR => '.type-' . $post_type->name . ' .entry-authorbox',
Super_Awesome_Theme_Customize_Partial::PROP_RENDER_CALLBACK => array( $this, 'partial_entry_authorbox' ),
Super_Awesome_Theme_Customize_Partial::PROP_CONTAINER_INCLUSIVE => true,
- 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 100.
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
if ( ! empty( $entry_attachment_meta_settings ) ) {
$customizer->add_partial( $post_type->name . '_entry_attachment_meta', array(
Super_Awesome_Theme_Customize_Partial::PROP_SETTINGS => $entry_attachment_meta_settings,
Super_Awesome_Theme_Customize_Partial::PROP_SELECTOR => '.type-' . $post_type->name . ' .entry-attachment-meta',
Super_Awesome_Theme_Customize_Partial::PROP_RENDER_CALLBACK => array( $this, 'partial_entry_attachment_meta' ),
- 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 99.
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
if ( ! empty( $entry_terms_settings ) ) {
$customizer->add_partial( $post_type->name . '_entry_terms', array(
Super_Awesome_Theme_Customize_Partial::PROP_SETTINGS => $entry_terms_settings,
Super_Awesome_Theme_Customize_Partial::PROP_SELECTOR => '.type-' . $post_type->name . ' .entry-terms',
Super_Awesome_Theme_Customize_Partial::PROP_RENDER_CALLBACK => array( $this, 'partial_entry_terms' ),
- 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 99.
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 5 locations. Consider refactoring. Open
$assets->register_asset( new Super_Awesome_Theme_Script(
'super-awesome-theme-content-types-customize-controls',
get_theme_file_uri( '/assets/dist/js/content-types.customize-controls.js' ),
array(
Super_Awesome_Theme_Script::PROP_DEPENDENCIES => array( 'customize-controls', 'wp-i18n' ),
- 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 94.
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