Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-288039: possible incomplete detection of "Possible multiple enumeration of IEnumerable" within .All() operator

$
0
0
Reporter Jakub Jiricek (jakub.jiricek@vodafone.com) Jakub Jiricek (jakub.jiricek@vodafone.com)
Created Jan 27, 2012 4:06:36 PM
Updated Jan 27, 2012 4:06:36 PM
Priority Normal
Type Bug
Fix versions No Fix versions
State Submitted
Assignee Unassigned
Subsystem Code Analysis
Affected versions 6.1.1
Fixed in build No Fixed in build
in the code
    private static bool checkStartBlock(IEnumerable<mux_trunk_allocationSpecialEDR> _paramAllocs, short capacity)
    {
      for (short ts = 1; ts <= capacity; ts ++)
        if (!checkAlloc(_paramAllocs, ts)) return false;
      return true;
    }

R# correctly warns about possible multiple enumeration of _paramAllocs (within checkAlloc method)
but the warning does not appear when the code is rewritten as
    private static bool checkStartBlock(IEnumerable<mux_trunk_allocationSpecialEDR> _paramAllocs, short capacity)
    {
      List<short> tsList = new List<short>();
      for (short ts = 1; ts <= capacity; ts++) tsList.Add(ts);
      return tsList.All(ts => checkAlloc(_paramAllocs, ts));
    }

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>