Dalphi/dalphi

View on GitHub

Showing 14 of 1,441 total issues

File project_spec.rb has 437 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rails_helper'

RSpec.describe Project, type: :model do
  before(:each) do
    @project = FactoryGirl.build(:project)
Severity: Minor
Found in spec/models/project_spec.rb - About 6 hrs to fix

    File statistics_spec.rb has 342 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'rails_helper'
    
    RSpec.describe 'Statistics API', type: :request do
      before(:each) do
        @auth_token = ApplicationController.generate_auth_token
    Severity: Minor
    Found in spec/requests/api/v1/statistics_spec.rb - About 4 hrs to fix

      Class ProjectsController has 29 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class ProjectsController < ApplicationController
        include ServiceRoles
      
        before_action :authenticate_user,
                      only: [:index, :show]
      Severity: Minor
      Found in app/controllers/projects_controller.rb - About 3 hrs to fix

        File annotation_documents_spec.rb has 306 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'rails_helper'
        
        RSpec.configure do |config|
          config.include AnnotationDocumentHelper
        end
        Severity: Minor
        Found in spec/requests/api/v1/annotation_documents_spec.rb - About 3 hrs to fix

          File raw_datum_spec.rb has 279 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'rails_helper'
          
          RSpec.describe RawDatum, type: :model do
            before(:each) do
              @raw_datum = FactoryGirl.build(:raw_datum)
          Severity: Minor
          Found in spec/models/raw_datum_spec.rb - About 2 hrs to fix

            File service_spec.rb has 264 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'rails_helper'
            
            RSpec.configure do |c|
              c.include ServiceHelper
            end
            Severity: Minor
            Found in spec/models/service_spec.rb - About 2 hrs to fix

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

                  def merge_annotation_documents
                    record_count = error_count = 0
                    @project.merge_data.each do |merge_datum|
                      response = merge_request merge_datum
                      if response.kind_of? Net::HTTPSuccess
              Severity: Minor
              Found in app/controllers/projects_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 a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def create
                      ActiveRecord::Base.transaction do
                        raw_data = []
                        raw_data_params.each do |rd_params|
                          @raw_datum = raw_datum_from_params(rd_params)
              Severity: Minor
              Found in app/controllers/api/v1/raw_data_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 new_service_flash_text has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def new_service_flash_text(uri)
                    if @service
                      @service.validate
                      url_error = @service.errors.details[:url].first
                      flash_text = I18n.t('services.searching.already-taken-url')
              Severity: Minor
              Found in app/controllers/services_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

              Avoid too many return statements within this method.
              Open

                  return action_label(token) if is_action?(token)
              Severity: Major
              Found in app/helpers/breadcrumb_bakery.rb - About 30 mins to fix

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

                  def self.process_zip_archive(project, zip, temp_dir)
                    require 'zip'
                    batch_result = { success: [], error: [] }
                    Zip::File.open(zip) do |zipfile|
                      zipfile.each do |file|
                Severity: Minor
                Found in app/models/raw_datum.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

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

                    def process_iteration_data(raw_data)
                      @annotation_documents = false
                      iterate_service = @project.iterate_service
                      response = json_post_request iterate_service.url,
                                                   process_iteration_data_response_hash(raw_data)
                Severity: Minor
                Found in app/controllers/projects_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

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

                  def self.batch_process(project, data)
                    return { error: [], success: [] } unless data || data == []
                    data_size = data.size
                    data_first = data.first.tempfile
                    if data_size == 1 && valid_zip?(data_first)
                Severity: Minor
                Found in app/models/raw_datum.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

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

                      def create
                        ActionController::Parameters.permit_all_parameters = true
                        annotation_documents = []
                        annotation_documents_params.each do |ad_params|
                          @annotation_document = AnnotationDocument.new(ad_params)
                Severity: Minor
                Found in app/controllers/api/v1/annotation_documents_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