SergioMadness/pwf

View on GitHub

Showing 9 of 330 total issues

Function validate has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate(array $data)
    {
        $rules = $this->getRules();
        foreach ($rules as $field => $rule) {
            if ((isset($rule['required']) && $rule['required'] === true && isset($data[$field]))
Severity: Minor
Found in framework/traits/Validatable.php - About 4 hrs 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 getTranslator has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getTranslator($type, array $params = [])
    {
        $result = null;

        if (!isset($params['language'])) {
Severity: Minor
Found in framework/components/i18n/Fabric.php - About 2 hrs to fix

    Function getTranslator has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getTranslator($type, array $params = [])
        {
            $result = null;
    
            if (!isset($params['language'])) {
    Severity: Minor
    Found in framework/components/i18n/Fabric.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

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

        public static function getHandlerByPath($path)
        {
            $result = null;
            $path   = self::prepareRoute('/'.trim($path, " /"));
    
    
    Severity: Minor
    Found in framework/basic/RouteHandler.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 run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function run()
        {
            try {
                $this->trigger(self::EVENT_APPLICATION_RUN);
    
    
    Severity: Minor
    Found in framework/basic/Application.php - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

                  if ((isset($rule['required']) && $rule['required'] === true && isset($data[$field]))
                      || ((!isset($rule['required']) || !$rule['required'])) && isset($data[$field])) {
                      foreach ($rule as $key => $value) {
                          if ($key !== 'required') {
                              foreach ($value as $validator) {
      Severity: Major
      Found in framework/traits/Validatable.php - About 1 hr to fix

        Function forceComponentLoading has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function forceComponentLoading()
            {
                $config = $this->getConfiguration();
                foreach ($config[self::COMPONENT_CONFIG_BLOCK] as $key => $params) {
                    if (isset($params['class']) && isset($params['force'])) {
        Severity: Minor
        Found in framework/basic/Application.php - About 35 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 translate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function translate($alias, array $params = [])
            {
                $result      = '';
                $translators = $this->getTranslators();
                foreach ($translators as $translator) {
        Severity: Minor
        Found in framework/components/i18n/Translator.php - About 35 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 detach has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function detach(Observer $observer, $type = 'default')
            {
                if (isset($this->observers[$type])) {
                    foreach ($this->observers[$type] as $key => $obs) {
                        if ($obs === $observer) {
        Severity: Minor
        Found in framework/components/observer/traits/Subject.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

        Severity
        Category
        Status
        Source
        Language