TrestleAdmin/trestle

View on GitHub

Showing 54 of 69 total issues

Method initialize has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

def initialize(admin, options={})
super(options) do |instance|
admin.default_form_attributes.each do |attribute|
if attribute.array?
if [:string, :text].include?(attribute.type)
Severity: Minor
Found in lib/trestle/form/automatic.rb - About 3 hrs to fix

Method autoformat_value has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def autoformat_value(value, **options)
case value
when Array
tag.ol(safe_join(value.map { |v|
tag.li(v.is_a?(Array) ? v : autoformat_value(v, **options)) },
Severity: Minor
Found in app/helpers/trestle/format_helper.rb - About 2 hrs to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

get confirmButton () {
const button = document.createElement('button')
 
button.classList.add('btn', 'btn-sm', this.confirmButtonClass)
button.textContent = this.confirmLabel
Severity: Major
Found in frontend/js/controllers/confirm_controller.js and 1 other location - About 2 hrs to fix
frontend/js/controllers/confirm_controller.js on lines 77..86

Similar blocks of code found in 2 locations. Consider refactoring.
Open

get cancelButton () {
const button = document.createElement('button')
 
button.classList.add('btn', 'btn-sm', this.cancelButtonClass)
button.textContent = this.cancelLabel
Severity: Major
Found in frontend/js/controllers/confirm_controller.js and 1 other location - About 2 hrs to fix
frontend/js/controllers/confirm_controller.js on lines 66..75

Similar blocks of code found in 2 locations. Consider refactoring.
Open

module Trestle
class Form
module Fields
class CollectionRadioButtons < Field
include RadioButtonHelpers
Severity: Major
Found in lib/trestle/form/fields/collection_radio_buttons.rb and 1 other location - About 2 hrs to fix
lib/trestle/form/fields/collection_check_boxes.rb on lines 1..33

Similar blocks of code found in 2 locations. Consider refactoring.
Open

module Trestle
class Form
module Fields
class CollectionCheckBoxes < Field
include CheckBoxHelpers
Severity: Major
Found in lib/trestle/form/fields/collection_check_boxes.rb and 1 other location - About 2 hrs to fix
lib/trestle/form/fields/collection_radio_buttons.rb on lines 1..33

Method destroy has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def destroy
if delete_instance
respond_to do |format|
flash[:message] = flash_message("destroy.success", title: "Success!", message: "The %{lowercase_model_name} was successfully deleted.")
 
 
Severity: Minor
Found in app/controllers/concerns/trestle/resource/controller/actions.rb - About 2 hrs to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

expand (list) {
list.classList.remove('collapsed')
 
const id = list.dataset.group
 
 
Severity: Major
Found in frontend/js/controllers/navigation_controller.js and 1 other location - About 1 hr to fix
frontend/js/controllers/navigation_controller.js on lines 59..66

Similar blocks of code found in 2 locations. Consider refactoring.
Open

collapse (list) {
list.classList.add('collapsed')
 
const id = list.dataset.group
 
 
Severity: Major
Found in frontend/js/controllers/navigation_controller.js and 1 other location - About 1 hr to fix
frontend/js/controllers/navigation_controller.js on lines 50..57

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

def create
if save_instance
respond_to do |format|
flash[:message] = flash_message("create.success", title: "Success!", message: "The %{lowercase_model_name} was successfully created.")
 
 
Severity: Minor
Found in app/controllers/concerns/trestle/resource/controller/actions.rb - About 1 hr to fix

Method column_value has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def column_value(instance)
if @column.block
if block_is_legacy_haml?
# In order for table column blocks to work properly within Haml templates,
# the _hamlout local variable needs to be defined in the scope of the block,
Severity: Minor
Found in lib/trestle/table/column.rb - About 1 hr to fix

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

def initialize(admin, options={})
super(options) do |instance|
admin.default_form_attributes.each do |attribute|
if attribute.array?
if [:string, :text].include?(attribute.type)
Severity: Minor
Found in lib/trestle/form/automatic.rb - About 1 hr to fix

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

    def show
    if admin.singular? && instance.nil?
    respond_to do |format|
    format.html { redirect_to action: :new }
    format.json { head :not_found }
    Severity: Minor
    Found in app/controllers/concerns/trestle/resource/controller/actions.rb - About 1 hr to fix

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

    def edit
    if admin.singular? && instance.nil?
    respond_to do |format|
    format.html { redirect_to action: :new }
    format.json { head :not_found }
    Severity: Minor
    Found in app/controllers/concerns/trestle/resource/controller/actions.rb - About 1 hr to fix

    Method admin_link_to has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def admin_link_to(content=nil, instance=nil, admin: nil, action: nil, method: nil, params: {}, **options, &block)
    # Block given - ignore content parameter and capture content from block
    if block_given?
    instance, content = content, capture(&block)
    end
    Severity: Minor
    Found in app/helpers/trestle/url_helper.rb - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    def show
    if admin.singular? && instance.nil?
    respond_to do |format|
    format.html { redirect_to action: :new }
    format.json { head :not_found }
    app/controllers/concerns/trestle/resource/controller/actions.rb on lines 67..83

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    def edit
    if admin.singular? && instance.nil?
    respond_to do |format|
    format.html { redirect_to action: :new }
    format.json { head :not_found }
    app/controllers/concerns/trestle/resource/controller/actions.rb on lines 48..64

    Method hsl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def hsl
    r = @r / 255.0
    g = @g / 255.0
    b = @b / 255.0
     
     
    Severity: Minor
    Found in lib/trestle/color.rb - About 1 hr to fix

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    module Trestle
    class Form
    module Fields
    class DateSelect < Field
    attr_reader :html_options
    Severity: Major
    Found in lib/trestle/form/fields/date_select.rb and 2 other locations - About 1 hr to fix
    lib/trestle/form/fields/datetime_select.rb on lines 1..20
    lib/trestle/form/fields/time_select.rb on lines 1..20

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    module Trestle
    class Form
    module Fields
    class TimeSelect < Field
    attr_reader :html_options
    Severity: Major
    Found in lib/trestle/form/fields/time_select.rb and 2 other locations - About 1 hr to fix
    lib/trestle/form/fields/date_select.rb on lines 1..20
    lib/trestle/form/fields/datetime_select.rb on lines 1..20
    Severity
    Category
    Status
    Source
    Language