timecard/timecard-rails

View on GitHub

Showing 22 of 39 total issues

Method create has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @issue = @project.issues.build(issue_params)
    authorize! :create, @issue
    respond_to do |format|
      if @issue.save
Severity: Minor
Found in app/controllers/issues_controller.rb - About 4 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 callback has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  def callback
    omniauth = request.env["omniauth.auth"]
    prov = omniauth.provider

    authentication = Authentication.where(provider: omniauth.provider, uid: omniauth.uid).first
Severity: Minor
Found in app/controllers/users/omniauth_callbacks_controller.rb - About 3 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 create has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    if params[:comment_and]
      @issue.toggle_status
    end

Severity: Minor
Found in app/controllers/comments_controller.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 update has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    respond_to do |format|
      if @issue.update(issue_params)
        if @issue.project.ruffnote && current_user.ruffnote
          issue = @issue.ruffnote.modify(
Severity: Minor
Found in app/controllers/issues_controller.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

Class Project has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class Project < ActiveRecord::Base
  STATUS_ACTIVE   = 1
  STATUS_CLOSED   = 5

  scope :active, -> { where(status: STATUS_ACTIVE) }
Severity: Minor
Found in app/models/project.rb - About 2 hrs to fix

    Method create has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create
        pjt = JSON.parse(params[:import].read)
        @project = Project.new(name: pjt["name"])
        @project.save
        Member.create(
    Severity: Minor
    Found in app/controllers/data_controller.rb - About 1 hr to fix

      Method callback has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def callback
          omniauth = request.env["omniauth.auth"]
          prov = omniauth.provider
      
          authentication = Authentication.where(provider: omniauth.provider, uid: omniauth.uid).first
      Severity: Minor
      Found in app/controllers/users/omniauth_callbacks_controller.rb - About 1 hr to fix

        Method create has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def create
            @issue = @project.issues.build(issue_params)
            authorize! :create, @issue
            respond_to do |format|
              if @issue.save
        Severity: Minor
        Found in app/controllers/issues_controller.rb - About 1 hr to fix

          Method create has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def create
              pjt = JSON.parse(params[:import].read)
              @project = Project.new(name: pjt["name"])
              @project.save
              Member.create(
          Severity: Minor
          Found in app/controllers/data_controller.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 create has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def create
              if params[:comment_and]
                @issue.toggle_status
              end
          
          
          Severity: Minor
          Found in app/controllers/comments_controller.rb - About 1 hr to fix

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

              def update
                respond_to do |format|
                  if @workload.update(workload_params)
                    if current_user.crowdworks && @workload.issue.project.crowdworks_contracts.exists?(["user_id = ?", current_user.id])
                      logging_crowdworks
            Severity: Minor
            Found in app/controllers/workloads_controller.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 reopen has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def reopen
                if @issue.reopen
                  if @issue.ruffnote
                    @issue.ruffnote.reopen(current_user.ruffnote.oauth_token)
                  end
            Severity: Minor
            Found in app/controllers/issues_controller.rb - About 55 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 close has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def close
                current_user.stop_time_track
            
                if @issue.close
                  if @issue.ruffnote
            Severity: Minor
            Found in app/controllers/issues_controller.rb - About 55 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 stop has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def stop
                respond_to do |format|
                  if @workload.update_attribute(:end_at, Time.now.utc)
                    if current_user.crowdworks && @workload.issue.project.crowdworks_contracts.exists?(["user_id = ?", current_user.id])
                      logging_crowdworks
            Severity: Minor
            Found in app/controllers/workloads_controller.rb - About 55 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

            Avoid deeply nested control flow statements.
            Open

                        rescue Net::SMTPAuthenticationError, Net::SMTPServerBusy, Net::SMTPSyntaxError, Net::SMTPFatalError, Net::SMTPUnknownError => e
                          logger.debug "[#{e.class}] #{e.message}"
            Severity: Major
            Found in app/controllers/users/omniauth_callbacks_controller.rb - About 45 mins to fix

              Method update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def update
                  respond_to do |format|
                    if @comment.update(comment_params)
                      format.html { redirect_to @comment.issue, notice: 'Comment was successfully updated.' }
                      format.json { render action: 'show', status: :created, location: @comment }
              Severity: Minor
              Found in app/controllers/comments_controller.rb - About 45 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 import_issues has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def import_issues
                  @client.issues.all(user: @owner, repo: @repo, filter: "all", state: "all").each_page do |github_issues|
                    github_issues.each do |github_issue|
                      if @issue_githubs.any? { |issue_github| issue_github.number == github_issue.number }
                        break
              Severity: Minor
              Found in app/services/github_importer.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 add_github has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def add_github(full_name, validate = true)
                  pg = ProjectGithub.find_or_create_by(
                      name: "github",
                      foreign_id: self.id,
                      provided_type: "Project"
              Severity: Minor
              Found in app/models/project.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 destroy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def destroy
                  if @comment.ruffnote && @comment.ruffnote.comment_id && current_user.ruffnote
                    comment = @comment.ruffnote.destroy(
                      current_user.ruffnote.oauth_token
                    )
              Severity: Minor
              Found in app/controllers/comments_controller.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 modify has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def modify(token, params)
                  options = {}
                  options["title"] = params[:subject] if params[:subject]
                  options["description"] = params[:description] if params[:description]
                  options["is_done"] = params[:state] unless params[:state].nil?
              Severity: Minor
              Found in app/models/issue_ruffnote.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