extinctionrebellion/RebelsManager

View on GitHub

Showing 32 of 37 total issues

Complex method namespace(mailtrain)::task#update_subscriptions (92.3)
Open

  task update_subscriptions: :environment do
    Rebel.all
      .includes(:skills, :tags, :working_groups)
      .find_each do |rebel|
      MailtrainService.instance.add_subscription(
Severity: Minor
Found in lib/tasks/mailtrain.rake by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method UiHelper#section_heading (64.1)
Open

  def section_heading(heading:, extra: nil, spacing: :hr, count: nil, icon: nil)
    out = ActiveSupport::SafeBuffer.new
    if spacing == :hr
      out << content_tag(:div, class: "grid-x") do
        content_tag(:div, class: "cell auto") do
Severity: Minor
Found in app/helpers/ui_helper.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method namespace(mailtrain)::task#update_subscriptions_for_local_group (50.4)
Open

  task :update_subscriptions_for_local_group, [:local_group_id] => :environment do |task, args|
    local_group = LocalGroup.find(args.local_group_id)
    if local_group.mailtrain_list_id.nil?
      puts "MailTrain list ID is not set for this local group."
    else
Severity: Minor
Found in lib/tasks/mailtrain.rake by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Function exports has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(api) {
  var validEnv = ['development', 'test', 'production']
  var currentEnv = api.env()
  var isDevelopmentEnv = api.env('development')
  var isProductionEnv = api.env('production')
Severity: Major
Found in babel.config.js - About 2 hrs to fix

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

      def section_heading(heading:, extra: nil, spacing: :hr, count: nil, icon: nil)
        out = ActiveSupport::SafeBuffer.new
        if spacing == :hr
          out << content_tag(:div, class: "grid-x") do
            content_tag(:div, class: "cell auto") do
    Severity: Minor
    Found in app/helpers/ui_helper.rb - About 2 hrs 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

    Complex method namespace(mailtrain)::task#update_subscriptions_for_main_list (45.7)
    Open

      task update_subscriptions_for_main_list: :environment do
        Rebel.all
          .includes(:skills, :tags, :working_groups)
          .find_each do |rebel|
          MailtrainService.instance.add_subscription(
    Severity: Minor
    Found in lib/tasks/mailtrain.rake by flog

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Complex method namespace(rebels)::task#import (43.8)
    Open

      task import: :environment do
        CSV.foreach(Rails.root.join("rebels.csv"), headers: false) do |row|
          email = row[1]
          begin
            rebel = Rebel.find_or_create_by(email: email) do |rebel|
    Severity: Minor
    Found in lib/tasks/rebels.rake by flog

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Method create_fields has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create_fields(mailtrain_list_id)
        MailtrainService.instance.create_field(
          mailtrain_list_id,
          {
            "NAME": "Postcode",
    Severity: Major
    Found in app/jobs/mailtrain/create_list_fields_job.rb - About 2 hrs to fix

      Complex method Rebels::ImportService#process_csv (40.7)
      Open

          def process_csv(content)
            csv = CSV.parse(content, headers: false)
            row_line = 0
            csv.each do |row|
              ActiveRecord::Base.transaction do
      Severity: Minor
      Found in app/services/rebels/import_service.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method CsvExport::Rebel#extract_info (37.7)
      Open

          def extract_info(rebel)
            [
              rebel.id,
              rebel.created_at.strftime("%b %d %Y"),
              rebel.local_group&.name,
      Severity: Minor
      Found in app/services/csv_export/rebel.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Method section_heading has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def section_heading(heading:, extra: nil, spacing: :hr, count: nil, icon: nil)
          out = ActiveSupport::SafeBuffer.new
          if spacing == :hr
            out << content_tag(:div, class: "grid-x") do
              content_tag(:div, class: "cell auto") do
      Severity: Minor
      Found in app/helpers/ui_helper.rb - About 1 hr to fix

        Complex method Mailtrain::AddSubscriptionsJob#subscribe_to_rebels_list (32.2)
        Open

          def subscribe_to_rebels_list(rebel)
            MailtrainService.instance.add_subscription(
              ENV['MAILTRAIN_REBELS_LIST_ID'],
              {
                "EMAIL": rebel.email,

        Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

        You can read more about ABC metrics or the flog tool

        Complex method Mailtrain::AddSubscriptionsJob#subscribe_to_rebels_local_list (29.2)
        Open

          def subscribe_to_rebels_local_list(rebel)
            return if rebel.local_group&.mailtrain_list_id.nil?
            MailtrainService.instance.add_subscription(
              rebel.local_group.mailtrain_list_id,
              {

        Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

        You can read more about ABC metrics or the flog tool

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

            def rebel_params(params)
              params
                .require(:rebel)
                .permit(
                  :agree_with_principles,
        Severity: Minor
        Found in app/services/rebels/update_service.rb - About 1 hr to fix

          Method callout has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def callout(type, content:, tiny: false, link_label: nil, link_href: nil, link_options: {})
              out = ActiveSupport::SafeBuffer.new
              if link_label && link_href
                out << content_tag(:div, class: "cell small-12 medium-shrink") do
                  if tiny
          Severity: Minor
          Found in app/helpers/ui_helper.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 decorate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def decorate(model, cache: false, reload: true)
              if model.present?
                base = model.class.name.underscore.gsub("/", "__")
                decorator_class = "#{model.class.name}Decorator".constantize
                decorator_var = "@#{base}_decorator"
          Severity: Minor
          Found in app/decorators/decorator_helpers.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

          Complex method RebelsController#update (25.8)
          Open

            def update
              service = Rebels::UpdateService.new(rebel: Rebel.find(params[:id]))
              if service.run(params)
                respond_to do |format|
                  format.html {
          Severity: Minor
          Found in app/controllers/rebels_controller.rb by flog

          Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

          You can read more about ABC metrics or the flog tool

          Complex method Public::RebelsController#update (25.6)
          Open

            def update
              @rebel = Rebel.find(params[:id])
              check_params(@rebel)
              service = Rebels::Public::UpdateService.new(rebel: @rebel)
              if service.run(params)

          Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

          You can read more about ABC metrics or the flog tool

          Complex method Public::RebelsController#check_params (25.0)
          Open

            def check_params(rebel)
              raise "Rebel not found" if rebel.nil?
              if rebel&.created_at&.to_i != params[:a]&.to_i ||
                  rebel.token != params[:c] ||
                    rebel.email.gsub(/\+/, " ") != params[:b]

          Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

          You can read more about ABC metrics or the flog tool

          Complex method Rebels::ImportsController#create (24.0)
          Open

            def create
              service = Rebels::ImportService.new
              if service.run(params)
                @csv_import = service.csv_import
                if !@csv_import.import_errors.any?

          Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

          You can read more about ABC metrics or the flog tool

          Severity
          Category
          Status
          Source
          Language