skyverge/wc-plugin-framework

View on GitHub
woocommerce/Settings_API/Abstract_Settings.php

Summary

Maintainability
B
6 hrs
Test Coverage

Function register_control has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function register_control( $setting_id, $type, array $args = [] ) {

        try {

            if ( ! in_array( $type, $this->get_control_types(), true ) ) {
Severity: Minor
Found in woocommerce/Settings_API/Abstract_Settings.php - About 1 hr to fix

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_control has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function register_control( $setting_id, $type, array $args = [] ) {

        try {

            if ( ! in_array( $type, $this->get_control_types(), true ) ) {
Severity: Minor
Found in woocommerce/Settings_API/Abstract_Settings.php - About 1 hr to fix

    Method register_setting has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function register_setting( $id, $type, array $args = [] ) {
    
            try {
    
                if ( ! empty( $this->settings[ $id ] ) ) {
    Severity: Minor
    Found in woocommerce/Settings_API/Abstract_Settings.php - About 1 hr to fix

      Function get_settings has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public function get_settings( array $ids = [] ) {
      
              $settings = $this->settings;
      
              if ( ! empty( $ids ) ) {
      Severity: Minor
      Found in woocommerce/Settings_API/Abstract_Settings.php - About 55 mins to fix

      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 save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public function save( $setting_id = '' ) {
      
              if ( ! empty( $setting_id ) ) {
                  $settings = [ $this->get_setting( $setting_id ) ];
              } else {
      Severity: Minor
      Found in woocommerce/Settings_API/Abstract_Settings.php - About 55 mins to fix

      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_setting has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function register_setting( $id, $type, array $args = [] ) {
      
              try {
      
                  if ( ! empty( $this->settings[ $id ] ) ) {
      Severity: Minor
      Found in woocommerce/Settings_API/Abstract_Settings.php - About 45 mins to fix

      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 get_value_from_database has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function get_value_from_database( $value, Setting $setting ) {
      
              if ( null !== $value ) {
      
                  switch ( $setting->get_type() ) {
      Severity: Minor
      Found in woocommerce/Settings_API/Abstract_Settings.php - About 25 mins to fix

      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

      There are no issues that match your filters.

      Category
      Status