Showing 183 of 288 total issues
Method from_html
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.from_html(html, line_length = 80, from_charset = 'UTF-8')
return "" if html.nil?
txt = html.dup
Method page_stats
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def page_stats
@page_type = params[:page_type]
# TODO verify page_type is valid
@commissions = BasilCommission.where(entity_type: @page_type)
Method review_year
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def review_year
@year = params[:year].to_i
comparable_year = "Jan 1, #{@year}".to_date
@created_content = {}
Method value_for
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def value_for(attribute_field, content)
case attribute_field.field_type
when 'link'
page_links = attribute_field.attribute_values.find_by(entity_type: content.class.name, entity_id: content.id)
if page_links.nil?
- 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 value_for
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def value_for(attribute_field, content)
case attribute_field.field_type
when 'link'
page_links = self.attribute_values.detect do |value|
value.entity_type == content.class.name && value.entity_id == content.id && value.attribute_field_id == attribute_field.id
- 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 text_markdown_export
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.text_markdown_export(universe_ids)
page_types = Rails.application.config.content_types[:all]
temporary_user_id_reference = Universe.find_by(id: universe_ids).user_id
export_text = StringIO.new
Method json_export
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.json_export(universe_ids)
page_types = Rails.application.config.content_types[:all]
temporary_user_id_reference = Universe.find_by(id: universe_ids).user_id
export_object = {}
Method text_outline_export
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.text_outline_export(universe_ids)
page_types = Rails.application.config.content_types[:all]
temporary_user_id_reference = Universe.find_by(id: universe_ids).user_id
export_text = StringIO.new
Method analyze
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.analyze(analysis_id)
analysis = ::DocumentAnalysis.find(analysis_id)
document = analysis.document
watson_client = new_client
Method perform
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def perform(*args)
document_id = args.shift
document = Document.find_by(id: document_id)
return unless document.present?
- 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 suggested_tags_for
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.suggested_tags_for(class_name)
case class_name
when Building.name
["School", "Business"]
when Character.name
Method commission
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def commission
@generated_images_count = current_user.basil_commissions.with_deleted.count
if !current_user.on_premium_plan? && @generated_images_count > BasilService::FREE_IMAGE_LIMIT
redirect_back fallback_location: basil_path, notice: "You've reached your free image limit. Please upgrade to generate more images."
return
- 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 migrate_fields_for_content
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.migrate_fields_for_content(content_model, user, force: false)
return unless content_model.present? && user.present?
return unless content_model.user == user
return if content_model.is_a?(ContentPage)
return if !force && content_model.persisted? && content_model.created_at > 'May 1, 2018'.to_datetime
Method relates
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.relates relation, with:#, where: {}
singularized_relation = relation.to_s.singularize
connecting_class = with.to_s.singularize.camelize.constantize
connecting_class_name = with
Function render
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
render () {
return (
<div id="entity-link-modal" className="modal">
<div className="modal-content">
<h4>Add a quick reference</h4>
Method api_sort
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def api_sort
sort_params = params.permit(:content_id, :intended_position, :sortable_class)
sortable_class = sort_params[:sortable_class].constantize # todo audit
return unless sortable_class
- 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 new
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def new
@content = content_type_from_controller(self.class)
.new(user: current_user)
.tap { |content|
content.name = "New #{content.class.name}"
- 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
Function render
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
render () {
return (
<React.Fragment>
<SpeedDial
ariaLabel="SpeedDial example"
Method replace_for
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.replace_for(text, user)
gremlins_phase = 1
replaced_text = text.dup
# Page tag replacements
Method cache_linkable_content_for_each_content_type
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def cache_linkable_content_for_each_content_type
cache_contributable_universe_ids
cache_current_user_content
linkable_classes = @activated_content_types
- 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"