OpenSourcePolitics/decidim-app

View on GitHub

Showing 29 of 33 total issues

Method html_template has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.html_template(until_period, organization_name)
        name = organization_name.presence || "our platform"

        "
<!DOCTYPE html>
Severity: Major
Found in lib/decidim_app/rack_attack/throttling.rb - About 3 hrs to fix

    File index.js has 278 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module.exports = { // eslint-disable-line
      "env": {
        "browser": true,
        "es6": true
      },
    Severity: Minor
    Found in packages/eslint-config/index.js - About 2 hrs to fix

      Class BackupService has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class BackupService
          def initialize(options)
            @options = default_options.merge(options)
            @local_files = []
          end
      Severity: Minor
      Found in app/services/decidim/backup_service.rb - About 2 hrs to fix

        Method update_each_column has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_each_column(record, columns)
              columns.each do |column|
                current_content = current_content_for(record, column)
                next if current_content.blank?
        
        
        Severity: Minor
        Found in app/services/decidim/repair_url_in_content_service.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

        Method backup_database has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def backup_database
              if can_connect_to_db?
                file_path = generate_backup_file_path("db", "dump")
        
                cmd = "pg_dump -Fc"
        Severity: Minor
        Found in app/services/decidim/backup_service.rb - About 1 hr 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 execute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def execute
              directory = service.directories.get(@options[:s3_bucket], prefix: subfolder)
        
              file_list.each do |filename|
                md5 = Digest::MD5.file(filename)
        Severity: Minor
        Found in app/services/decidim/s3_sync_service.rb - About 1 hr 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

        Function overrideSassRule has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const overrideSassRule = (modifyConfig) => {
          const sassRule = modifyConfig.module.rules.find(
            (rule) => rule.test.toString() === "/\\.(scss|sass)(\\.erb)?$/i"
          );
          if (!sassRule) {
        Severity: Minor
        Found in packages/webpacker/src/override-config.js - About 1 hr to fix

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

                def self.get_redirection_target(host, limit = 3)
                  return nil if limit.zero? # Avoid infinite loops
                  return nil unless host.is_a?(URI) || host.is_a?(String)
          
                  url = URI(host)
          Severity: Minor
          Found in lib/decidim_app/k8s/secondary_hosts_checker.rb - About 1 hr 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 organization_settings has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def organization_settings
                  {
                    apiVersion: "apps.libre.sh/v1alpha1",
                    kind: "Decidim",
                    metadata: {
          Severity: Minor
          Found in lib/decidim_app/k8s/organization_exporter.rb - About 1 hr to fix

            Method execute has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def execute
                  directory = service.directories.get(@options[:s3_bucket], prefix: subfolder)
            
                  file_list.each do |filename|
                    md5 = Digest::MD5.file(filename)
            Severity: Minor
            Found in app/services/decidim/s3_sync_service.rb - About 1 hr to fix

              Method replace_urls has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def replace_urls(doc, tag)
                    attribute = tag == "img" ? "src" : "href"
              
                    doc.css(tag).each do |source|
                      next unless source[attribute].include?(@deprecated_endpoint)
              Severity: Minor
              Found in lib/decidim/content_fixer.rb - About 1 hr 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 apply_configuration has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def self.apply_configuration
                    Rack::Attack.throttled_response_retry_after_header = true
              
                    Rack::Attack.throttled_responder = lambda do |request|
                      rack_logger = Logger.new(Rails.root.join("log/rack_attack.log"))
              Severity: Minor
              Found in lib/decidim_app/rack_attack.rb - About 1 hr to fix

                Function overrideSassRule has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                const overrideSassRule = (modifyConfig) => {
                  const sassRule = modifyConfig.module.rules.find(
                    (rule) => rule.test.toString() === "/\\.(scss|sass)(\\.erb)?$/i"
                  );
                  if (!sassRule) {
                Severity: Minor
                Found in packages/webpacker/src/override-config.js - 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 execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def execute
                      create_backup_dir
                
                      if has_enough_disk_space?
                        create_backup_export
                Severity: Minor
                Found in app/services/decidim/backup_service.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 repair has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def repair(content = @content)
                      if content.is_a?(Hash)
                        content.transform_values { |value| repair(value) }
                      elsif content.is_a?(Array)
                        content.map { |value| repair(value) }
                Severity: Minor
                Found in lib/decidim/content_fixer.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 apply_configuration has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.apply_configuration
                      Decidim::Initiatives.configure do |c|
                        c.creation_enabled = creation_enabled? unless Rails.application.secrets.dig(:decidim, :initiatives, :creation_enabled) == "auto"
                        c.similarity_threshold = similarity_threshold
                        c.similarity_limit = similarity_limit
                Severity: Minor
                Found in lib/decidim_app/decidim_initiatives.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 files_digest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def files_digest(patterns)
                      patterns.map { |pattern| Dir.glob(pattern) }
                              .flatten
                              .sort
                              .each_with_object({}) do |file, result|
                Severity: Minor
                Found in lib/decidim/assets_hash.rb - About 45 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 resource_icon has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def resource_icon(resource, options = {})
                    if resource.instance_of?(Decidim::Initiative)
                      icon "initiatives", options
                    elsif resource.instance_of?(Decidim::Comments::Comment)
                      icon "comment-square", options
                Severity: Minor
                Found in lib/extends/helpers/decidim/icon_helper_extends.rb - About 45 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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def run
                      # Find all models that have a column of type string jsonb or text
                      # For each model, find all records that have a column of type string jsonb or text
                      # For each record, replace all urls contained in content with the new url
                      # Save the record
                Severity: Minor
                Found in app/services/decidim/repair_url_in_content_service.rb - About 45 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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def initialize(resource, field_name, text, target_locale, source_locale)
                Severity: Minor
                Found in app/services/deepl_translator.rb - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language