elephantly/AmpConverterBundle

View on GitHub

Showing 25 of 164 total issues

Method callback has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function callback()
    {
        switch ($this->outputElement->getAttribute('data-do')) {
            case 'embedPin':
                if (!$this->outputElement->getAttribute('data-url')) {
Severity: Major
Found in Converter/Social/AmpPinterestConverter.php - About 3 hrs to fix

    Function callback has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public function callback()
        {
            switch ($this->outputElement->getAttribute('data-do')) {
                case 'embedPin':
                    if (!$this->outputElement->getAttribute('data-url')) {
    Severity: Minor
    Found in Converter/Social/AmpPinterestConverter.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 getConfigTreeBuilder has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getConfigTreeBuilder()
        {
            $treeBuilder = new TreeBuilder();
            $rootNode = $treeBuilder->root('elephantly_amp_converter');
    
    
    Severity: Minor
    Found in DependencyInjection/Configuration.php - About 1 hr to fix

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

          public function convertToAmp($element)
          {
              // Initialize
              $this->inputElement = $element;
              $this->isInputValid = true;
      Severity: Minor
      Found in Converter/AmpTagConverter.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 callback has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public function callback()
          {
              $this->outputElement->setAttribute('sandbox', isset($this->options['sandbox']) ? $this->options['sandbox'] : '');
      
              if (!AmpDimensionsCleaner::isLegal($this->outputElement->getAttribute('width'))) {
      Severity: Minor
      Found in Converter/Layout/AmpIframeConverter.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 convert has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public function convert($input)
          {
              if (!$input) {
                  return '';
              }
      Severity: Minor
      Found in Converter/AmpConverter.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 callback has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public function callback()
          {
              $src = $this->inputElement->getAttribute('data-href');
              preg_match('/https:\/\/www.facebook\.com\/\w*\/(\w*)\/\d*/', $src, $embedType);
              switch ($embedType) {
      Severity: Minor
      Found in Converter/Social/AmpFacebookSdkConverter.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 callback has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function callback()
          {
              $src = $this->inputElement->getAttribute('data-href');
              preg_match('/https:\/\/www.facebook\.com\/\w*\/(\w*)\/\d*/', $src, $embedType);
              switch ($embedType) {
      Severity: Minor
      Found in Converter/Social/AmpFacebookSdkConverter.php - About 1 hr to fix

        Method convert has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function convert($input)
            {
                if (!$input) {
                    return '';
                }
        Severity: Minor
        Found in Converter/AmpConverter.php - About 1 hr to fix

          Function callback has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public function callback()
              {
                  $isConsistent = (AmpDimensionsCleaner::isLegal($this->outputElement->getAttribute('width')) && AmpDimensionsCleaner::isLegal($this->outputElement->getAttribute('height')));
          
                  if (!$isConsistent) {
          Severity: Minor
          Found in Converter/Media/AmpDailymotionIframeConverter.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 getDefaultValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getDefaultValue($attribute)
              {
                  switch ($attribute) {
                      case 'layout':
                          return 'responsive';
          Severity: Minor
          Found in Converter/Social/AmpTwitterConverter.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 callback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function callback()
              {
          
                  foreach ($this->inputElement->childNodes as $tag) {
          
          
          Severity: Minor
          Found in Converter/Media/AmpAudioConverter.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 callback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function callback()
              {
          
                  foreach ($this->inputElement->childNodes as $tag) {
          
          
          Severity: Minor
          Found in Converter/Media/AmpVideoConverter.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

                          return $this->oembed['height'] ? $this->oembed['height'] : 400;
          Severity: Major
          Found in Converter/Social/AmpInstagramConverter.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return 315;
            Severity: Major
            Found in Converter/Media/AmpYoutubeIframeConverter.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return null;
              Severity: Major
              Found in Converter/Social/AmpFacebookSdkConverter.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return null;
                Severity: Major
                Found in Converter/Social/AmpFacebookIframeConverter.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return null;
                  Severity: Major
                  Found in Converter/Social/AmpTwitterConverter.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return null;
                    Severity: Major
                    Found in Converter/Social/AmpInstagramConverter.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return '486';
                      Severity: Major
                      Found in Converter/Social/AmpTwitterConverter.php - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language