whiteCube/lingua

View on GitHub

Showing 4 of 36 total issues

File languages.php has 2216 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
* This file should always return an array containing
* the languages data. Please follow the structure 
Severity: Major
Found in languages.php - About 6 days to fix

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

        public static function find($format, $value)
        {
            $instance = self::getInstance();
            foreach ($instance->languages as $language) {
                if(!isset($language[$format])) continue;
    Severity: Minor
    Found in src/Lingua/LanguagesRepository.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 guess has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function guess(string $format)
        {
            $matches = [];
            foreach (self::$converters as $key => $converter) {
                if(!call_user_func_array($converter . '::check', [$format])) continue;
    Severity: Minor
    Found in src/Lingua/Service.php - About 45 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 format has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function format(ConverterInterface $converter)
        {
            if(!$converter->repository) {
                throw new \Exception('Language "' . $converter . '" could not be converted to its english name since it is not registered in the Lingua repository');
            }
    Severity: Minor
    Found in src/Lingua/NameConverter.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

    Severity
    Category
    Status
    Source
    Language