darylldoyle/svg-sanitizer

View on GitHub

Showing 21 of 21 total issues

Method getAttributes has 329 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getAttributes()
    {
        return array(
            // HTML
            'about',
Severity: Major
Found in src/data/AllowedAttributes.php - About 1 day to fix

    Function startClean has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function startClean(\DOMNodeList $elements, array $elementsToRemove)
        {
            // loop through all elements
            // we do this backwards so we don't skip anything if we delete a node
            // see comments at: http://php.net/manual/en/class.domnamednodemap.php
    Severity: Minor
    Found in src/Sanitizer.php - About 5 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

    File Sanitizer.php has 363 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    namespace enshrined\svgSanitize;
    
    use enshrined\svgSanitize\data\AllowedAttributes;
    use enshrined\svgSanitize\data\AllowedTags;
    Severity: Minor
    Found in src/Sanitizer.php - About 4 hrs to fix

      File AllowedAttributes.php has 337 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      namespace enshrined\svgSanitize\data;
      
      /**
       * Class AllowedAttributes
      Severity: Minor
      Found in src/data/AllowedAttributes.php - About 4 hrs to fix

        Sanitizer has 32 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Sanitizer
        {
        
            /**
             * @var \DOMDocument
        Severity: Minor
        Found in src/Sanitizer.php - About 4 hrs to fix

          Method getTags has 72 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function getTags()
              {
                  return array (
                      // HTML
                      'a',
          Severity: Major
          Found in src/data/AllowedTags.php - About 2 hrs to fix

            Method startClean has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function startClean(\DOMNodeList $elements, array $elementsToRemove)
                {
                    // loop through all elements
                    // we do this backwards so we don't skip anything if we delete a node
                    // see comments at: http://php.net/manual/en/class.domnamednodemap.php
            Severity: Major
            Found in src/Sanitizer.php - About 2 hrs to fix

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

                  protected function cleanAttributesOnWhitelist(\DOMElement $element)
                  {
                      for ($x = $element->attributes->length - 1; $x >= 0; $x--) {
                          // get attribute name
                          $attrName = $element->attributes->item($x)->nodeName;
              Severity: Minor
              Found in src/Sanitizer.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 isHrefSafeValue has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function isHrefSafeValue($value) {
              
                      // Allow empty values
                      if (empty($value)) {
                          return true;
              Severity: Minor
              Found in src/Sanitizer.php - About 1 hr to fix

                Method cleanAttributesOnWhitelist has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function cleanAttributesOnWhitelist(\DOMElement $element)
                    {
                        for ($x = $element->attributes->length - 1; $x >= 0; $x--) {
                            // get attribute name
                            $attrName = $element->attributes->item($x)->nodeName;
                Severity: Minor
                Found in src/Sanitizer.php - About 1 hr to fix

                  Method sanitize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function sanitize($dirty)
                      {
                          // Don't run on an empty string
                          if (empty($dirty)) {
                              return '';
                  Severity: Minor
                  Found in src/Sanitizer.php - About 1 hr to fix

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

                        protected function determineInvalidSubjects()
                        {
                            foreach ($this->subjects as $subject) {
                    
                                if (in_array($subject->getElement(), $this->elementsToRemove)) {
                    Severity: Minor
                    Found in src/ElementReference/Resolver.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

                    Avoid deeply nested control flow statements.
                    Open

                                            if (in_array(strtolower($attrName), ['face', 'color', 'size'])) {
                                                $breaksOutOfForeignContent = true;
                                            }
                    Severity: Major
                    Found in src/Sanitizer.php - About 45 mins to fix

                      Function processReferences has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function processReferences()
                          {
                              $useNodeName = $this->xPath->createNodeName('use');
                              foreach ($this->subjects as $subject) {
                                  $useElements = $this->xPath->query(
                      Severity: Minor
                      Found in src/ElementReference/Resolver.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 isElementContainedIn has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function isElementContainedIn(\DOMElement $needle, \DOMElement $haystack)
                          {
                              if ($needle === $haystack) {
                                  return true;
                              }
                      Severity: Minor
                      Found in src/Helper.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 isHrefSafeValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function isHrefSafeValue($value) {
                      
                              // Allow empty values
                              if (empty($value)) {
                                  return true;
                      Severity: Minor
                      Found in src/Sanitizer.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 false;
                      Severity: Major
                      Found in src/Sanitizer.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return true;
                        Severity: Major
                        Found in src/Sanitizer.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return true;
                          Severity: Major
                          Found in src/Sanitizer.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return true;
                            Severity: Major
                            Found in src/Sanitizer.php - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language