gistflow/gistflow

View on GitHub

Showing 5 of 15 total issues

Class User has 32 methods (exceeds 20 allowed). Consider refactoring.
Open

class User < ActiveRecord::Base
  include Models::Todolistable

  delegate :token, to: :account_token

Severity: Minor
Found in app/models/user.rb - About 4 hrs to fix

    Method initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(user)
        # simple authorization like self.current_user = User.first
        can :create, :sessions if development?
        
        can :show, :sitemap
    Severity: Minor
    Found in app/models/ability.rb - About 1 hr to fix

      Method find_or_create_by_omniauth has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.find_or_create_by_omniauth(omniauth)
          token = omniauth['credentials']['token']
          ActiveRecord::Base.transaction do
            find_by_github_id(omniauth['uid']) || create! do |account|
              account.token     = token
      Severity: Minor
      Found in app/models/account/github.rb - About 1 hr 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 safe_replace has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def safe_replace
          # extract replaceable tags
          replaceable = {}
          REPLACEABLE_TAGS.each do |tag|
            @html.gsub!(%r{<#{tag}>.*?</#{tag}>}m) do |match|
      Severity: Minor
      Found in app/models/replaceable.rb - About 1 hr to fix

        Method show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def show
            if @tag = Tag.find_by_name(params[:id])
              redirect_to @tag.entity if @tag.alias?
              
              @posts = Post.not_private.tagged_with(@tag.name).page(params[:page])
        Severity: Minor
        Found in app/controllers/tags_controller.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

        Severity
        Category
        Status
        Source
        Language