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

View data dictionaries should be replaced by models

    Details

    • Message:
      Replace all uses of "[ViewBag|ViewData]" with model.
    • Highlighting:
      Hide

      Primary: The first edition of ViewBag/ViewData in a method

      Secondary:

      • location: Every other occurence of ViewBag/ViewData.
      • message: Replace this use of "[ViewBag/ViewData]".
      Show
      Primary: The first edition of ViewBag/ViewData in a method Secondary: location: Every other occurence of ViewBag/ViewData. message: Replace this use of " [ViewBag/ViewData] ".
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Targeted languages:
      C#, VB.Net
    • Irrelevant for Languages:
      ABAP, APEX, C, C++, Cobol, CSS, Flex, Go, HTML, Java, JavaScript, Kotlin, Objective-C, PHP, PL/I, PL/SQL, Python, RPG, Ruby, Rust, Scala, Solidity, Swift, T-SQL, TypeScript, VB6, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      3h
    • Analysis Level:
      Syntactic Analysis
    • Analysis Scope:
      Main Sources

      Description

      ViewBag and ViewData dictionaries enable controllers to pass data to their views as weakly typed collections. Reading the provided values is dynamically resolved at runtime without any compile-time checking. This can lead to unexpected behavior, since reading a missing value does not produce an exception.

      Controllers should pass data to their views via a strongly typed view model class.

      See

      Views in ASP.NET Core MVC - Weakly typed data

        Attachments

          Issue Links

          1.
          C# RSPEC-5771 Language-Specification Active Unassigned
          2.
          VB.NET RSPEC-5772 Language-Specification Active Unassigned

            Activity

              People

              • Assignee:
                nicolas.harraudeau Nicolas Harraudeau (Inactive)
                Reporter:
                pavel.mikula Pavel Mikula
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: