Commit graph

10 commits

Author SHA1 Message Date
Sean McGivern
e9476eb97a Speed up cached_pass? for composite rules
Both `Or` and `And` would evaluate whether each rule passed, then calculate a
value based on the results of all of those. We can actually return early in many
cases, without running the rule at all.
2017-10-05 10:12:58 +01:00
Sean McGivern
d771719278 Speed up DeclarativePolicy::Runner#steps_by_score
There were a couple of things here:

1. If the state was already enabled, we don't need to check all the remaining
   steps - only those that can prevent the state. (An enable followed by an
   enable is a no-op.) This logic is in `#run`, but we still did the work of
   scoring and sorting the steps.
2. The sorting is known to be inefficient, but we can make it slightly more
   efficient by stopping once we have a step with zero score, as that means it's
   free.

Neither of these make this _fast_, especially when called lots of times - as we
do when there is lots of activity on an issue - but they do help some.
2017-10-04 13:50:05 +01:00
Rémy Coutable
fcce6c3168 Merge branch 'rs-more-public-send-whitelists' into 'master'
Whitelist or fix additional `Gitlab/PublicSend` cop violations

See merge request !13467
2017-08-16 11:25:26 +00:00
Robert Speicher
4edfad9678 Enable Layout/TrailingWhitespace cop and auto-correct offenses 2017-08-15 13:44:37 -04:00
Robert Speicher
260c8da060 Whitelist or fix additional Gitlab/PublicSend cop violations
An upcoming update to rubocop-gitlab-security added additional
violations.
2017-08-14 12:14:11 -04:00
http://jneen.net/
15bb6e1ed7 more eagerly bail when the state is prevented 2017-08-07 12:48:22 -07:00
http://jneen.net/
8a167554a9 reduce iterations by keeping a count of remaining enablers
rather than iterating the whole remaining step set with
.all?(&:prevent?)
2017-08-07 12:36:13 -07:00
http://jneen.net/
fcd3e5d477 cache the cache key... 2017-07-17 14:38:48 -07:00
http://jneen.net/
45e9d28791 avoid #respond_to? in Cache.id_for 2017-07-17 14:38:48 -07:00
http://jneen.net/
80d6e5bbd4 add a new DeclarativePolicy framework 2017-06-27 12:41:54 -07:00