timegridio/icalreader

View on GitHub

Showing 22 of 22 total issues

Function process_recurrences has a Cognitive Complexity of 146 (exceeds 5 allowed). Consider refactoring.
Open

    public function process_recurrences()
    {
        $array = $this->cal;
        $events = $array['VEVENT'];

Severity: Minor
Found in src/ICalParser.php - About 2 days 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 process_recurrences has 223 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process_recurrences()
    {
        $array = $this->cal;
        $events = $array['VEVENT'];

Severity: Major
Found in src/ICalParser.php - About 1 day to fix

    File ICalParser.php has 473 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Timegridio\ICalReader;
    
    /**
    Severity: Minor
    Found in src/ICalParser.php - About 7 hrs to fix

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

                                      if ($event_start_timestamp > $start_timestamp && $event_start_timestamp < $until) {
                                          $anEvent['DTSTART'] = date('Ymd\T', $event_start_timestamp).$start_time;
                                          $anEvent['DTEND'] = date('Ymd\THis', $this->iCalDateToUnixTimestamp($anEvent['DTSTART']) + $event_timestamp_offset);
      
                                          $search_date = $anEvent['DTSTART'];
      Severity: Major
      Found in src/ICalParser.php and 2 other locations - About 4 hrs to fix
      src/ICalParser.php on lines 576..586
      src/ICalParser.php on lines 606..616

      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 164.

      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

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

                                      if ($event_start_timestamp > $start_timestamp && $event_start_timestamp < $until) {
                                          $anEvent['DTSTART'] = date('Ymd\T', $event_start_timestamp).$start_time;
                                          $anEvent['DTEND'] = date('Ymd\THis', $this->iCalDateToUnixTimestamp($anEvent['DTSTART']) + $event_timestamp_offset);
      
                                          $search_date = $anEvent['DTSTART'];
      Severity: Major
      Found in src/ICalParser.php and 2 other locations - About 4 hrs to fix
      src/ICalParser.php on lines 532..542
      src/ICalParser.php on lines 576..586

      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 164.

      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

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

                                      if ($event_start_timestamp > $start_timestamp && $event_start_timestamp < $until) {
                                          $anEvent['DTSTART'] = date('Ymd\T', $event_start_timestamp).$start_time;
                                          $anEvent['DTEND'] = date('Ymd\THis', $this->iCalDateToUnixTimestamp($anEvent['DTSTART']) + $event_timestamp_offset);
      
                                          $search_date = $anEvent['DTSTART'];
      Severity: Major
      Found in src/ICalParser.php and 2 other locations - About 4 hrs to fix
      src/ICalParser.php on lines 532..542
      src/ICalParser.php on lines 606..616

      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 164.

      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

      Further Reading

      Function initLines has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function initLines($lines)
          {
              if (stristr($lines[0], 'BEGIN:VCALENDAR') === false) {
                  return false;
              }
      Severity: Minor
      Found in src/ICalParser.php - About 3 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

      Function addCalendarComponentWithKeyAndValue has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public function addCalendarComponentWithKeyAndValue($component, $keyword, $value)
          {
              if ($keyword == false) {
                  $keyword = $this->last_keyword;
              }
      Severity: Minor
      Found in src/ICalParser.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 initLines has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function initLines($lines)
          {
              if (stristr($lines[0], 'BEGIN:VCALENDAR') === false) {
                  return false;
              }
      Severity: Major
      Found in src/ICalParser.php - About 2 hrs to fix

        Function keyValueFromString has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public function keyValueFromString($text)
            {
                // Match colon separator outside of quoted substrings
                // Fallback to nearest semicolon outside of quoted substrings, if colon cannot be found
                // Do not try and match within the value paired with the keyword
        Severity: Minor
        Found in src/ICalParser.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 addCalendarComponentWithKeyAndValue has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function addCalendarComponentWithKeyAndValue($component, $keyword, $value)
            {
                if ($keyword == false) {
                    $keyword = $this->last_keyword;
                }
        Severity: Minor
        Found in src/ICalParser.php - About 1 hr to fix

          Method keyValueFromString has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function keyValueFromString($text)
              {
                  // Match colon separator outside of quoted substrings
                  // Fallback to nearest semicolon outside of quoted substrings, if colon cannot be found
                  // Do not try and match within the value paired with the keyword
          Severity: Minor
          Found in src/ICalParser.php - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                                                if (!$is_excluded) {
                                                    $events[] = $anEvent;
                                                }
            Severity: Major
            Found in src/ICalParser.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                                  if (!$is_excluded) {
                                                      $events[] = $anEvent;
                                                  }
              Severity: Major
              Found in src/ICalParser.php - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                if ($event_start_timestamp > $start_timestamp && $event_start_timestamp < $until) {
                                                    $anEvent['DTSTART'] = date('Ymd\T', $event_start_timestamp).$start_time;
                                                    $anEvent['DTEND'] = date('Ymd\THis', $this->iCalDateToUnixTimestamp($anEvent['DTSTART']) + $event_timestamp_offset);
                
                                                    $search_date = $anEvent['DTSTART'];
                Severity: Major
                Found in src/ICalParser.php - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                      if (!$is_excluded) {
                                                          $events[] = $anEvent;
                                                      }
                  Severity: Major
                  Found in src/ICalParser.php - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                        if (!$is_excluded) {
                                                            $events[] = $anEvent;
                                                        }
                    Severity: Major
                    Found in src/ICalParser.php - About 45 mins to fix

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

                          public function eventsFromRange($rangeStart = false, $rangeEnd = false)
                          {
                              $events = $this->sortEventsWithOrder($this->events(), SORT_ASC);
                      
                              if (!$events) {
                      Severity: Minor
                      Found in src/ICalParser.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

                      Avoid too many return statements within this method.
                      Open

                                                          $is_excluded = array_filter($anEvent['EXDATE_array'], function ($val) use ($search_date) { return is_string($val) && strpos($search_date, $val) === 0; });
                      Severity: Major
                      Found in src/ICalParser.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                                            $is_excluded = array_filter($anEvent['EXDATE_array'], function ($val) use ($search_date) { return is_string($val) && strpos($search_date, $val) === 0; });
                        Severity: Major
                        Found in src/ICalParser.php - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language