keboola/php-utils

View on GitHub

Showing 9 of 61 total issues

Function getDataFromPath has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function getDataFromPath($path, $data, $separator = "/", $ignoreEmpty = true)
{
    if (isset($path) && $path !== $separator) {
        // TODO possibly add functions in the $path? Such as path/to/join(data) would do a join on that data..likely belongs to EX/(sub)Parser/TR
        $str = explode($separator, $path);
Severity: Minor
Found in src/Keboola/Utils/getDataFromPath.php - About 2 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 jsonDecode has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function jsonDecode($json, $assoc = false, $depth = 512, $options = 0, $logJson = false, $lint = false)
{
    $data = json_decode($json, $assoc, $depth, $options);
    switch (json_last_error()) {
        case JSON_ERROR_NONE:
Severity: Minor
Found in src/Keboola/Utils/jsonDecode.php - About 1 hr to fix

    Function jsonDecode has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    function jsonDecode($json, $assoc = false, $depth = 512, $options = 0, $logJson = false, $lint = false)
    {
        $data = json_decode($json, $assoc, $depth, $options);
        switch (json_last_error()) {
            case JSON_ERROR_NONE:
    Severity: Minor
    Found in src/Keboola/Utils/jsonDecode.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 buildUrl has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    function buildUrl($url, array $query = null)
    {
        if (!empty($query)) {
            // Cleanup the input array to prevent empty Keys
            foreach ($query as $k => $v) {
    Severity: Minor
    Found in src/Keboola/Utils/buildUrl.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 buildUrl has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function buildUrl($url, array $query = null)
    {
        if (!empty($query)) {
            // Cleanup the input array to prevent empty Keys
            foreach ($query as $k => $v) {
    Severity: Minor
    Found in src/Keboola/Utils/buildUrl.php - About 1 hr to fix

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

      function isEmptyObject(\stdClass $object)
      {
          $vars = get_object_vars($object);
          if ($vars == []) {
              return true;
      Severity: Minor
      Found in src/Keboola/Utils/isEmptyObject.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 castToBool has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      function castToBool($castToBool): bool
      {
          if (is_string($castToBool)) {
              if ($castToBool === '1') {
                  return true;
      Severity: Minor
      Found in src/Keboola/Utils/castToBool.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

      Method jsonDecode has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function jsonDecode($json, $assoc = false, $depth = 512, $options = 0, $logJson = false, $lint = false)
      Severity: Minor
      Found in src/Keboola/Utils/jsonDecode.php - About 45 mins to fix

        Avoid too many return statements within this method.
        Open

            return false;
        Severity: Major
        Found in src/Keboola/Utils/castToBool.php - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language