next-l/enju_leaf

View on GitHub
app/models/concerns/enju_seed/enju_user.rb

Summary

Maintainability
C
7 hrs
Test Coverage
A
90%

Method export has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def self.export(options = {format: :text})
        header = %w(
          username
          full_name
          full_name_transcription
Severity: Minor
Found in app/models/concerns/enju_seed/enju_user.rb - About 2 hrs to fix

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 export has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.export(options = {format: :text})
        header = %w(
          username
          full_name
          full_name_transcription
Severity: Major
Found in app/models/concerns/enju_seed/enju_user.rb - About 2 hrs to fix

    Method deletable_by? has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def deletable_by?(current_user)
          return nil unless current_user
    
          if defined?(EnjuCirculation)
            # 未返却の資料のあるユーザを削除しようとした
    Severity: Minor
    Found in app/models/concerns/enju_seed/enju_user.rb - About 2 hrs to fix

    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 check_expiration has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_expiration
          return if has_role?('Administrator')
    
          if expired_at
            if expired_at.beginning_of_day < Time.zone.now.beginning_of_day
    Severity: Minor
    Found in app/models/concerns/enju_seed/enju_user.rb - About 35 mins to fix

    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 has_role? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def has_role?(role_in_question)
          return false unless role
          return true if role.name == role_in_question
    
          case role.name
    Severity: Minor
    Found in app/models/concerns/enju_seed/enju_user.rb - About 25 mins to fix

    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

    There are no issues that match your filters.

    Category
    Status