Commit bf06eafb authored by Philipp Wolfer's avatar Philipp Wolfer

AngularJS check: Removed caching

This was removed from all checks in a0009086
parent 821d3b39
......@@ -47,23 +47,20 @@ class AngularJSInterpolationCheck(TargetCheck):
default_disabled = True
severity = 'danger'
def check_single(self, source, target, unit, cache_slot):
def check_single(self, source, target, unit):
# Verify unit is properly flagged
if self.enable_string not in unit.all_flags:
return False
# Try geting source parsing from cache
src_match = self.get_cache(unit, cache_slot)
src_match = ANGULARJS_INTERPOLATION_MATCH.findall(source)
# Cache miss
if src_match is None:
src_match = ANGULARJS_INTERPOLATION_MATCH.findall(source)
self.set_cache(unit, src_match, cache_slot)
# Any interpolation strings in source?
if len(src_match) == 0:
return False
# Parse target
tgt_match = ANGULARJS_INTERPOLATION_MATCH.findall(target)
# Fail the check if the number of matches is different
if len(src_match) != len(tgt_match):
return True
......
......@@ -36,50 +36,42 @@ class AngularJSInterpolationCheckTest(TestCase):
self.assertFalse(self.check.check_single(
'strins',
'string',
MockUnit('angularjs_no_format', flags='angularjs-format'),
0
MockUnit('angularjs_no_format', flags='angularjs-format')
))
def test_format(self):
self.assertFalse(self.check.check_single(
u'{{name}} string {{other}}',
u'{{name}} {{other}} string',
MockUnit('angularjs_format', flags='angularjs-format'),
0
MockUnit('angularjs_format', flags='angularjs-format')
))
def test_format_ignore_position(self):
self.assertFalse(self.check.check_single(
u'{{name}} string {{other}}',
u'{{other}} string {{name}}',
MockUnit(
'angularjs_format_ignore_position',
flags='angularjs-format'),
0
MockUnit('angularjs_format_ignore_position',
flags='angularjs-format')
))
def test_different_whitespace(self):
self.assertFalse(self.check.check_single(
u'{{ name }} string',
u'{{name}} string',
MockUnit(
'angularjs_different_whitespace',
flags='angularjs-format'),
0
MockUnit('angularjs_different_whitespace',
flags='angularjs-format')
))
def test_missing_format(self):
self.assertTrue(self.check.check_single(
u'{{name}} string',
u'string',
MockUnit('angularjs_missing_format', flags='angularjs-format'),
0
MockUnit('angularjs_missing_format', flags='angularjs-format')
))
def test_wrong_value(self):
self.assertTrue(self.check.check_single(
u'{{name}} string',
u'{{nameerror}} string',
MockUnit('angularjs_wrong_value', flags='angularjs-format'),
0
MockUnit('angularjs_wrong_value', flags='angularjs-format')
))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment