fisharebest/webtrees

View on GitHub
app/Module/YahrzeitModule.php

Summary

Maintainability
C
1 day
Test Coverage

Function getBlock has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string
    {
        $calendar_service = new CalendarService();

        $days      = (int) $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS);
Severity: Minor
Found in app/Module/YahrzeitModule.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 getBlock has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string
    {
        $calendar_service = new CalendarService();

        $days      = (int) $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS);
Severity: Major
Found in app/Module/YahrzeitModule.php - About 3 hrs to fix

    Consider simplifying this complex logical expression.
    Open

                            if ($hd->day === 30 && $hd->month === 2 && $hd->year !== 0 && $hd1->daysInMonth() < 30) {
                                // 30 CSH - Last day in CSH
                                $jd_yahrtzeit = $jewish_calendar->ymdToJd($today->year, 3, 1) - 1;
                            } elseif ($hd->day === 30 && $hd->month === 3 && $hd->year !== 0 && $hd1->daysInMonth() < 30) {
                                // 30 KSL - Last day in KSL
    Severity: Critical
    Found in app/Module/YahrzeitModule.php - About 2 hrs to fix

      There are no issues that match your filters.

      Category
      Status