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

"propTypes" structure names should follow a naming convention

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Closed
    • Resolution: Won't Fix
    • Message:
      Rename "XXX" to match the regular expression ${format}.
    • Highlighting:
      Hide

      Primary: the wrongly named property

      Show
      Primary: the wrongly named property
    • List of parameters:
      Hide
      • key: BooleanType
        • description:React.PropTypes.bool
        • default: ^(is|has)[A-Z]([A-Za-z0-9]?)+
      • key: others
        • description:React.PropTypes.bool
        • default: ^[a-z]([A-Za-z0-9]?)+
      Show
      key: BooleanType description:React.PropTypes.bool default: ^(is|has) [A-Z] ( [A-Za-z0-9] ?)+ key: others description:React.PropTypes.bool default: ^ [a-z] ( [A-Za-z0-9] ?)+
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way
    • Targeted languages:
      JavaScript
    • Irrelevant for Languages:
      ABAP, C#, C, C++, Cobol, CSS, Flex, HTML, Java, Objective-C, PHP, PL/I, PL/SQL, Python, RPG, Swift, T-SQL, TypeScript, VB.Net, VB6, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2min
    • Analysis Scope:
      Main Sources

      Description

      Shared coding conventions allow teams to collaborate efficiently. This rule checks that all members of a propTypes structure match a provided regular expression.

      Noncompliant Code Example

      Using the default regular expressions: (is|has)[A-Z]([A-Za-z0-9]?), [a-z]([A-Za-z0-9]?)

        static propTypes = {
          enabled: React.PropTypes.bool.isRequired, // Noncompliant
          max_loops: React.PropTypes.number.isRequired, // Noncompliant
          FrameSrc: React.PropTypes.string.isRequired, // Noncompliant
        }
      

      Compliant Solution

        static propTypes = {
          isEnabled: React.PropTypes.bool.isRequired,
          maxLoops: React.PropTypes.number.isRequired,
          frameSrc: React.PropTypes.string.isRequired,
        }
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            alexandre.gigleux Alexandre Gigleux
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: