gam6itko/jms-serializer-config-converter

View on GitHub

Showing 22 of 22 total issues

Function loadFromFile has a Cognitive Complexity of 107 (exceeds 5 allowed). Consider refactoring.
Confirmed

    protected function loadFromFile(\ReflectionClass $class, string $path): ?ClassConfig
    {
        $previous = libxml_use_internal_errors(true);
        libxml_clear_errors();

Severity: Minor
Found in src/Normalizer/XmlNormalizer.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

Function toString has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Confirmed

    public function toString(ClassConfig $config): string
    {
        $xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><serializer/>');
        $classEl = $xml->addChild('class');

Severity: Minor
Found in src/Denormalizer/XmlDenormalizer.php - About 1 day 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 loadFromFile has 185 lines of code (exceeds 25 allowed). Consider refactoring.
Confirmed

    protected function loadFromFile(\ReflectionClass $class, string $path): ?ClassConfig
    {
        $previous = libxml_use_internal_errors(true);
        libxml_clear_errors();

Severity: Major
Found in src/Normalizer/XmlNormalizer.php - About 7 hrs to fix

    Function fillProperty has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        private function fillProperty($propConf, array $annotations = [])
        {
            if (!$annotations) {
                return;
            }
    Severity: Minor
    Found in src/Normalizer/AnnotationNormalizer.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

    Function collectFolders has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        private function collectFolders(string $targetNamespace): array
        {
            $classLoader = $this->getClassLoader();
            $targetNsArr = explode('\\', trim($targetNamespace, '\\'));
    
    
    Severity: Minor
    Found in src/Command/ConvertCommand.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 parseMethods has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        private function parseMethods(\ReflectionClass $class, ClassConfig $config): void
        {
            $callbacks = [
                PreSerialize::class    => 'preSerialize',
                PostSerialize::class   => 'postSerialize',
    Severity: Minor
    Found in src/Normalizer/AnnotationNormalizer.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 normalize has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        public function normalize(\ReflectionClass $class): ?ClassConfig
        {
            if ($class->isAbstract()) {
                return null;
            }
    Severity: Minor
    Found in src/Normalizer/AnnotationNormalizer.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 fillProperty has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function fillProperty($propConf, array $annotations = [])
        {
            if (!$annotations) {
                return;
            }
    Severity: Major
    Found in src/Normalizer/AnnotationNormalizer.php - About 2 hrs to fix

      Method toString has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function toString(ClassConfig $config): string
          {
              $xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><serializer/>');
              $classEl = $xml->addChild('class');
      
      
      Severity: Major
      Found in src/Denormalizer/XmlDenormalizer.php - About 2 hrs to fix

        Function addProperty has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            private function addProperty(\SimpleXMLElement $classEl, string $nodeName, $config)
            {
                $propEl = $classEl->addChild($nodeName);
                $properties = $this->extractClassPropertyTypes(new \ReflectionClass($config));
                foreach ($properties as $propertyName => $type) {
        Severity: Minor
        Found in src/Denormalizer/XmlDenormalizer.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 normalize has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function normalize(\ReflectionClass $class): ?ClassConfig
            {
                if ($class->isAbstract()) {
                    return null;
                }
        Severity: Major
        Found in src/Normalizer/AnnotationNormalizer.php - About 2 hrs to fix

          Function collectClasses has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              private function collectClasses(string $namespace, string $folder): array
              {
                  $result = [];
                  foreach (scandir($folder) as $item) {
                      if (\in_array($item, ['.', '..'])) {
          Severity: Minor
          Found in src/Command/ConvertCommand.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 collectFolders has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function collectFolders(string $targetNamespace): array
              {
                  $classLoader = $this->getClassLoader();
                  $targetNsArr = explode('\\', trim($targetNamespace, '\\'));
          
          
          Severity: Minor
          Found in src/Command/ConvertCommand.php - About 1 hr to fix

            Method addProperty has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function addProperty(\SimpleXMLElement $classEl, string $nodeName, $config)
                {
                    $propEl = $classEl->addChild($nodeName);
                    $properties = $this->extractClassPropertyTypes(new \ReflectionClass($config));
                    foreach ($properties as $propertyName => $type) {
            Severity: Minor
            Found in src/Denormalizer/XmlDenormalizer.php - About 1 hr to fix

              Method parseMethods has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function parseMethods(\ReflectionClass $class, ClassConfig $config): void
                  {
                      $callbacks = [
                          PreSerialize::class    => 'preSerialize',
                          PostSerialize::class   => 'postSerialize',
              Severity: Minor
              Found in src/Normalizer/AnnotationNormalizer.php - About 1 hr to fix

                Function toArray has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function toArray($configObject)
                    {
                        $reflection = new \ReflectionClass($configObject);
                
                        $result = [];
                Severity: Minor
                Found in src/Denormalizer/YamlDenormalizer.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 parseDiscriminator has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function parseDiscriminator(\SimpleXMLElement $elem)
                    {
                        $discriminator = new DiscriminatorConfig();
                        $discriminator->fieldName = (string) $elem->attributes()->{'discriminator-field-name'};
                        $discriminator->disabled = filter_var($elem->attributes()->{'discriminator-disabled'}, FILTER_VALIDATE_BOOLEAN);
                Severity: Minor
                Found in src/Normalizer/XmlNormalizer.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 getClassLoader has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function getClassLoader(): ClassLoader
                    {
                        $folder = __DIR__;
                        while ($pathToComposer = $this->findComposerJson($folder)) {
                            $composerConfig = json_decode(file_get_contents($pathToComposer), true);
                Severity: Minor
                Found in src/Command/ConvertCommand.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 denormalize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function denormalize(ClassConfig $config)
                    {
                        if (!$this->namespaceFolders) {
                            throw new \LogicException('You must define at least one namespace folder');
                        }
                Severity: Minor
                Found in src/Denormalizer/AbstractFileDenormalizer.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

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

                    private function listOf(string $class, $array)
                    {
                        if (!\is_array($array)) {
                            return null;
                        }
                Severity: Minor
                Found in src/Normalizer/YamlNormalizer.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