Avoided assignment followed by immediate return.

Identified using the following command:

$ pcre2grep --line-number --multiline --recursive \
    "(?s)(\n +)(\w+) = [^\n]+\1return \2;?$" \
    django docs extras js_tests scripts tests
This commit is contained in:
Nick Pope 2022-10-28 14:51:34 +01:00 committed by Mariusz Felisiak
parent d3cb91db87
commit 2bc47d7fe9
5 changed files with 6 additions and 12 deletions

View File

@ -26,13 +26,11 @@
} }
function addPopupIndex(name) { function addPopupIndex(name) {
name = name + "__" + (popupIndex + 1); return name + "__" + (popupIndex + 1);
return name;
} }
function removePopupIndex(name) { function removePopupIndex(name) {
name = name.replace(new RegExp("__" + (popupIndex + 1) + "$"), ''); return name.replace(new RegExp("__" + (popupIndex + 1) + "$"), '');
return name;
} }
function showAdminPopup(triggeringLink, name_regexp, add_popup) { function showAdminPopup(triggeringLink, name_regexp, add_popup) {

View File

@ -163,8 +163,7 @@
s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces
s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens
s = s.substring(0, num_chars); // trim to first num_chars chars s = s.substring(0, num_chars); // trim to first num_chars chars
s = s.replace(/-+$/g, ''); // trim any trailing hyphens return s.replace(/-+$/g, ''); // trim any trailing hyphens
return s;
} }
window.URLify = URLify; window.URLify = URLify;
} }

View File

@ -110,8 +110,7 @@ class Polygon(GEOSGeometry):
if isinstance(param, LinearRing): if isinstance(param, LinearRing):
return param return param
try: try:
ring = LinearRing(param) return LinearRing(param)
return ring
except TypeError: except TypeError:
raise TypeError(msg) raise TypeError(msg)

View File

@ -1027,8 +1027,7 @@ class ETagGZipMiddlewareTest(SimpleTestCase):
""" """
def get_response(req): def get_response(req):
response = HttpResponse(self.compressible_string) return HttpResponse(self.compressible_string)
return response
def get_cond_response(req): def get_cond_response(req):
return ConditionalGetMiddleware(get_response)(req) return ConditionalGetMiddleware(get_response)(req)

View File

@ -156,8 +156,7 @@ class TestSuiteTests(SimpleTestCase):
def make_tests(self): def make_tests(self):
"""Return an iterable of tests.""" """Return an iterable of tests."""
suite = self.make_test_suite() suite = self.make_test_suite()
tests = list(iter_test_cases(suite)) return list(iter_test_cases(suite))
return tests
def test_shuffle_tests(self): def test_shuffle_tests(self):
tests = self.make_tests() tests = self.make_tests()