Refactor: can use MOOC.fi tokens to authenticate #541
mipyykko wants to merge
refactor-moocfi-tokens
into master
Failed
2 issues to fix.
Method create_or_update_user_from_moocfi
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. New
New
def create_or_update_user_from_moocfi(moocfi_user)
# in case we have a discrepancy, ie. MOOC.fi user and TMC user both exist, but MOOC.fi user doesn't have TMC id
user = User.find_by(email: moocfi_user['email'])
if user
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method update_moocfi_user
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. New
New
def update_moocfi_user(user)
base_url_for_moocfi = SiteSetting.value('base_url_for_moocfi')
moocfi_update_secret = SiteSetting.value('moocfi_update_secret')
begin
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Category
Status
File | Maintainability |
app/controllers/api/v8/base_controller.rb |