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

Components should have explicit data types

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Specify the type of this (attribute|element).
    • Highlighting:
      Hide

      xs:(element|attribute)

      Show
      xs:(element|attribute)
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • 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

      Omitting the data type of an attribute or element leaves it to default to xs:any for elements, and xs:anyType for attributes. However there is no reason for making such a significant design decision implicit..

      Noncompliant Code Example

      <xs:element name="fruit">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="color"/> <!-- Noncompliant -->
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      

      Compliant Solution

      <xs:element name="fruit">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="color" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      

        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: