jenkins-bot merged this change.

View Change

Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
[IMPR] Avoid too many return statements within function

(reported by codeclimate)

Change-Id: I0ba7855a831116627e11e1f2e4b813448835280f
---
M pywikibot/bot.py
1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index f79dd69..7bbdc81 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -2057,9 +2057,11 @@
'Skipping %s because claim with same property '
'already exists' % (claim.getID(),))
log('Use -exists:p option to override this behavior')
- return False
+ break
+
if not existing.target_equals(claim.getTarget()):
continue
+
# If some attribute of the claim being added
# matches some attribute in an existing claim of
# the same property, skip the claim, unless the
@@ -2069,19 +2071,22 @@
'Skipping %s because claim with same target already exists'
% (claim.getID(),))
log("Append 't' to -exists argument to override this behavior")
- return False
+ break
+
if 'q' not in exists_arg and not existing.qualifiers:
logger_callback(
'Skipping %s because claim without qualifiers already '
'exists' % (claim.getID(),))
log("Append 'q' to -exists argument to override this behavior")
- return False
+ break
+
if ('s' not in exists_arg or not source) and not existing.sources:
logger_callback(
'Skipping %s because claim without source already exists'
% (claim.getID(),))
log("Append 's' to -exists argument to override this behavior")
- return False
+ break
+
if ('s' not in exists_arg and source
and any(source.getID() in ref
and all(snak.target_equals(source.getTarget())
@@ -2091,9 +2096,11 @@
'Skipping %s because claim with the same source already '
'exists' % (claim.getID(),))
log("Append 's' to -exists argument to override this behavior")
- return False
+ break
+ else:
+ return self.user_add_claim(item, claim, source, **kwargs)

- return self.user_add_claim(item, claim, source, **kwargs)
+ return False

def create_item_for_page(self, page, data=None, summary=None, **kwargs):
"""

To view, visit change 508128. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I0ba7855a831116627e11e1f2e4b813448835280f
Gerrit-Change-Number: 508128
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)