redmine/redmine

View on GitHub
app/models/setting.rb

Summary

Maintainability
D
1 day
Test Coverage

File setting.rb has 288 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Setting < ApplicationRecord
  PASSWORD_CHAR_CLASSES = {
    'uppercase'     => /[A-Z]/,
    'lowercase'     => /[a-z]/,
    'digits'        => /[0-9]/,
Severity: Minor
Found in app/models/setting.rb - About 2 hrs to fix

    Method validate_all_from_params has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.validate_all_from_params(settings)
        messages = []
        [
          [:mail_handler_enable_regex_delimiters,
           :mail_handler_body_delimiters,
    Severity: Minor
    Found in app/models/setting.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

    Class Setting has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Setting < ApplicationRecord
      PASSWORD_CHAR_CLASSES = {
        'uppercase'     => /[A-Z]/,
        'lowercase'     => /[a-z]/,
        'digits'        => /[0-9]/,
    Severity: Minor
    Found in app/models/setting.rb - About 2 hrs to fix

      Method validate_all_from_params has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.validate_all_from_params(settings)
          messages = []
          [
            [:mail_handler_enable_regex_delimiters,
             :mail_handler_body_delimiters,
      Severity: Minor
      Found in app/models/setting.rb - About 1 hr to fix

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

          def self.set_all_from_params(settings)
            return nil unless settings.is_a?(Hash)
        
            settings = settings.dup.symbolize_keys
        
        
        Severity: Minor
        Found in app/models/setting.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 commit_update_keywords_array has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.commit_update_keywords_array
            a = []
            if commit_update_keywords.is_a?(Array)
              commit_update_keywords.each do |rule|
                next unless rule.is_a?(Hash)
        Severity: Minor
        Found in app/models/setting.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 commit_update_keywords_from_params has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.commit_update_keywords_from_params(params)
            s = []
            if params.is_a?(Hash) && params.key?(:keywords) && params.values.all?(Array)
              attributes = params.except(:keywords).keys
              params[:keywords].each_with_index do |keywords, i|
        Severity: Minor
        Found in app/models/setting.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 force_utf8_strings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def force_utf8_strings(arg)
            if arg.is_a?(String)
              arg.dup.force_encoding('UTF-8')
            elsif arg.is_a?(Array)
              arg.map do |a|
        Severity: Minor
        Found in app/models/setting.rb - About 25 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

        There are no issues that match your filters.

        Category
        Status