File api_communicator.rb
has 275 lines of code (exceeds 250 allowed). Consider refactoring. Open
module BawWorkers
class ApiCommunicator
attr_accessor :logger
Method send_request
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send_request(description, method, host, port, endpoint, security_info = {auth_token: nil, cookies: nil}, body = nil)
case method
when :get
request = Net::HTTP::Get.new(endpoint)
Method send_request
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def send_request(description, method, host, port, endpoint, security_info = {auth_token: nil, cookies: nil}, body = nil)
case method
when :get
request = Net::HTTP::Get.new(endpoint)
- 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_analysis_jobs_item_status
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_analysis_jobs_item_status(analysis_job_id, audio_recording_id, status, security_info)
approved_statuses = [:working, :successful, :failed, :timed_out, :cancelled]
raise "Cannot set status to `#{status}`" unless approved_statuses.include?(status)
Method update_analysis_jobs_item_status
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def update_analysis_jobs_item_status(analysis_job_id, audio_recording_id, status, security_info)
approved_statuses = [:working, :successful, :failed, :timed_out, :cancelled]
raise "Cannot set status to `#{status}`" unless approved_statuses.include?(status)
- 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 request_login
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def request_login
login_response = send_request('Login request', :post, host, port, endpoint_login, nil, {email: user, password: password})
# get cookies
# from http://stackoverflow.com/a/9320190/31567
Method send_request
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def send_request(description, method, host, port, endpoint, security_info = {auth_token: nil, cookies: nil}, body = nil)
Method get_analysis_jobs_item_status
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_analysis_jobs_item_status(analysis_job_id, audio_recording_id, security_info)
endpoint = endpoint_analysis_jobs_item_update_status
.gsub(':audio_recording_id', audio_recording_id.to_s)
.gsub(':analysis_job_id', analysis_job_id.to_s)
- 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_audio_recording_details
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def update_audio_recording_details(description, file_to_process, audio_recording_id, update_hash, security_info)
Method create_new_audio_recording
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_new_audio_recording(file_to_process, project_id, site_id, audio_info_hash, security_info)
Method update_audio_recording_status
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def update_audio_recording_status(description, file_to_process, audio_recording_id, update_hash, security_info)