Finesse/web-fonts-repository

View on GitHub

Showing 8 of 9 total issues

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

    public static function createFromSettings(string $id, $settings): self
    {
        if (!preg_match('/^([0-9]+)(i?)$/i', $id, $matches)) {
            throw new InvalidSettingsException("The style identifier `$id` has invalid format.");
        }
Severity: Minor
Found in src/Services/WebfontCSSGenerator/Models/Style.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 makeFontStyleCSS has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function makeFontStyleCSS(string $familyName, string $styleName, string $fontDisplay = ''): string
    {
        // Does the given family exist?
        $family = $this->getFontFamily($familyName);
        if (!$family) {
Severity: Minor
Found in src/Services/WebfontCSSGenerator/WebfontCSSGenerator.php - About 1 hr to fix

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

        protected function makeFontStyleCSS(string $familyName, string $styleName, string $fontDisplay = ''): string
        {
            // Does the given family exist?
            $family = $this->getFontFamily($familyName);
            if (!$family) {
    Severity: Minor
    Found in src/Services/WebfontCSSGenerator/WebfontCSSGenerator.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 createFromSettings has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function createFromSettings(string $id, $settings): self
        {
            if (!preg_match('/^([0-9]+)(i?)$/i', $id, $matches)) {
                throw new InvalidSettingsException("The style identifier `$id` has invalid format.");
            }
    Severity: Minor
    Found in src/Services/WebfontCSSGenerator/Models/Style.php - About 1 hr to fix

      Method __invoke has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
          {
              // Getting and checking the request data
              $requestParams = $request->getQueryParams();
              if (!isset($requestParams['family'])) {
      Severity: Minor
      Found in src/Controllers/CSSGeneratorController.php - About 1 hr to fix

        Function checkAndFilterPathArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected static function checkAndFilterPathArray(array $parts, string $prefix = 'Part #'): array
            {
                $result = [];
        
                foreach ($parts as $index => $part) {
        Severity: Minor
        Found in src/Helpers/FileHelpers.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

        Function parseFamilyParameter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function parseFamilyParameter(string $value): array
            {
                $result = [];
                $families = explode('|', $value);
        
        
        Severity: Minor
        Found in src/Controllers/CSSGeneratorController.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

        Function makeFontFamilyCSS has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function makeFontFamilyCSS(string $name, array $styles = ['400'], string $fontDisplay = ''): string
            {
                $cssCode = '';
                $readyStyles = [];
        
        
        Severity: Minor
        Found in src/Services/WebfontCSSGenerator/WebfontCSSGenerator.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