Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Suspicious code fragments found by PVS-Studio #146

Open
@AGB-DevRel

Description

@AGB-DevRel

Hello
I found some suspicious fragments in the project source code with the help of the PVS-Studio static analyzer.
A few suspicious code snippets are bellow. Perhaps some of them are worth fixing.

Issue 1

private void OnDrawGizmosSelected(){  ....  var vehicles = FindObjectsOfType<Vehicle>()                .Where(....)                .OrderBy(....)                .ToArray();  foreach (var vehicle in vehicles)  {    foreach (var seat in vehicle.Seats){....}    var closestSeat = vehicle.GetSeatAlignmentOfClosestSeat(transform.position);    if (closestSeat != Vehicle.SeatAlignment.None){....}    break;  }}

Link to the sources
A break occurs under any circumstances on the first iteration of the loop. As a result, only the first element from the entire vehicles collection will be used in the loop.

Issue 2

public void SetString(string key, string value){  if (m_syncDictionary.TryGetValue(key, out string existingValue))  {    if (value != existingValue)    {      m_syncDictionary[key] = value; // <=    }  }  m_syncDictionary[key] = value; // <=}

Link to the sources
The m_syncDictionary[key] = value assignment occurs regardless of the check results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp