messages: Remove some unnecessary zephyr code paths.

The comments explain why this change is correct.  This change is
useful because it's better to not have dead code paths, both because
it makes our life easier for coverage analysis, and because the else
statement provided the illusion that it could actually happen.

If the analysis in that comment is wrong, we'd rather have a 500 error
so we fix the bug than things silently sorta working.
This commit is contained in:
Tim Abbott
2017-02-22 16:06:04 -08:00
parent ff37524db6
commit 8dba310bee

View File

@@ -173,10 +173,10 @@ class NarrowBuilder(object):
# MIT users expect narrowing to "social" to also show messages to /^(un)*social(.d)*$/ # MIT users expect narrowing to "social" to also show messages to /^(un)*social(.d)*$/
# (unsocial, ununsocial, social.d, etc) # (unsocial, ununsocial, social.d, etc)
m = re.search(r'^(?:un)*(.+?)(?:\.d)*$', stream.name, re.IGNORECASE) m = re.search(r'^(?:un)*(.+?)(?:\.d)*$', stream.name, re.IGNORECASE)
if m: # Since the regex has a `.+` in it and "" is invalid as a
# stream name, this will always match
assert(m is not None)
base_stream_name = m.group(1) base_stream_name = m.group(1)
else:
base_stream_name = stream.name
matching_streams = get_active_streams(self.user_profile.realm).filter( matching_streams = get_active_streams(self.user_profile.realm).filter(
name__iregex=r'^(un)*%s(\.d)*$' % (self._pg_re_escape(base_stream_name),)) name__iregex=r'^(un)*%s(\.d)*$' % (self._pg_re_escape(base_stream_name),))
@@ -195,10 +195,9 @@ class NarrowBuilder(object):
# MIT users expect narrowing to topic "foo" to also show messages to /^foo(.d)*$/ # MIT users expect narrowing to topic "foo" to also show messages to /^foo(.d)*$/
# (foo, foo.d, foo.d.d, etc) # (foo, foo.d, foo.d.d, etc)
m = re.search(r'^(.*?)(?:\.d)*$', operand, re.IGNORECASE) m = re.search(r'^(.*?)(?:\.d)*$', operand, re.IGNORECASE)
if m: # Since the regex has a `.*` in it, this will always match
assert(m is not None)
base_topic = m.group(1) base_topic = m.group(1)
else:
base_topic = operand
# Additionally, MIT users expect the empty instance and # Additionally, MIT users expect the empty instance and
# instance "personal" to be the same. # instance "personal" to be the same.