Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-3842

Unused prefixes should be removed

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Remove this prefix; it isn't used in the XSD.
    • Highlighting:
      Hide

      xs:some-prefix="some-namespace"

      Show
      xs:some-prefix="some-namespace"
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way
    • Targeted languages:
      XML
    • Irrelevant for Languages:
      ABAP, C#, C, C++, Cobol, CSS, Flex, HTML, Java, JavaScript, Objective-C, PHP, PL/I, PL/SQL, Python, RPG, Swift, VB.Net, VB6
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Scope:
      Main Sources, Test Sources

      Description

      Namespace prefixes that are declared but not used simply clutter the document and confuse maintainers. Such prefixes should be removed.

      Noncompliant Code Example

      <xs:schema targetNamespace="http://www.codeSamples.com/fruit"
                 xmlns:xs="http://www.w3.org/2001/XMLSchema"
                 xmlns:animal="http://www.codeSamples.com/animal"
                 elementFormDefault="qualified" version="1">  <!-- Noncompliant -->
        <xs:element name="fruit">
          <xs:complexType>
            <xs:sequence>
              ...                        <!-- assume that no use of prefix "animal" is made here -->
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:schema>
      

      Compliant Solution

      <xs:schema targetNamespace="http://www.codeSamples.com/fruit"
                 xmlns:xs="http://www.w3.org/2001/XMLSchema"
                 elementFormDefault="qualified" version="1">
        <xs:element name="fruit">
          <xs:complexType>
            <xs:sequence>
              ...                        <!-- assume that no use of prefix "animal" is made here -->
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:schema>
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            ann.campbell.2 Ann Campbell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: