AlchemyCMS/alchemy_cms

View on GitHub

Showing 31 of 58 total issues

Method delete_multiple has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def delete_multiple
if request.delete? && params[:picture_ids].present?
pictures = Picture.find(params[:picture_ids])
names = []
not_deletable = []
Severity: Minor
Found in app/controllers/alchemy/admin/pictures_controller.rb - About 1 hr to fix

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

    def run_on_page_layout_callbacks
    OnPageLayout.callbacks.each do |page_layout, callbacks|
    next unless call_page_layout_callback_for?(page_layout)
     
    callbacks.each do |callback|
    Severity: Minor
    Found in lib/alchemy/on_page_layout/callbacks_runner.rb - About 45 mins to fix

    Method update_element_positions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def update_element_positions
    Alchemy::Page.all.each do |page|
    if page.elements.any?
    puts "\n## Updating element positions of page `#{page.name}`"
    end
    Severity: Minor
    Found in lib/alchemy/tasks/tidy.rb - About 35 mins to fix

    Method page_hash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def page_hash(page, level, folded)
    p_hash = {
    id: page.id,
    name: page.name,
    public: page.public?,
    Severity: Minor
    Found in app/serializers/alchemy/page_tree_serializer.rb - About 35 mins to fix

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

    def create
    @page_version = PageVersion.find(params[:element][:page_version_id])
    @page = @page_version.page
    Element.transaction do
    @paste_from_clipboard = params[:paste_from_clipboard].present?
    Severity: Minor
    Found in app/controllers/alchemy/admin/elements_controller.rb - About 35 mins to fix

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

    def redirect_to_success_page
    flash[:notice] = Alchemy.t(:success, scope: "contactform.messages")
    urlname = if success_page
    success_page_urlname
    elsif mailer_config["forward_to_page"] && mailer_config["mail_success_page"]
    Severity: Minor
    Found in app/controllers/alchemy/messages_controller.rb - About 25 mins to fix

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

    def call
    return if picture.blank?
     
    output = caption ? img_tag + caption : img_tag
     
     
    Severity: Minor
    Found in app/components/alchemy/ingredients/picture_view.rb - About 25 mins to fix

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

    def set_alchemy_language(lang = nil)
    @language = if lang
    lang.is_a?(Language) ? lang : load_alchemy_language_from_id_or_code(lang)
    else
    load_alchemy_language_from_params || Language.default
    Severity: Minor
    Found in lib/alchemy/controller_actions.rb - About 25 mins to fix

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

    def copy_children_to(new_parent)
    children.each do |child|
    next if child == new_parent
     
    new_child = Alchemy::CopyPage.new(page: child).call(changed_attributes: {
    Severity: Minor
    Found in app/models/alchemy/page.rb - About 25 mins to fix

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

    def set_primary_language(code: "en", name: "English", auto_accept: false)
    unless auto_accept
    code = ask("- What is the language code of your site's primary language?", default: code)
    end
    unless auto_accept
    Severity: Minor
    Found in lib/alchemy/install/tasks.rb - About 25 mins to fix

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

    def remove_orphaned_elements
    puts "\n## Removing orphaned elements"
    elements = Alchemy::Element.unscoped.not_nested
    if elements.any?
    orphaned_elements = elements.select do |element|
    Severity: Minor
    Found in lib/alchemy/tasks/tidy.rb - About 25 mins to fix
    Severity
    Category
    Status
    Source
    Language