takahashim/cheepub

View on GitHub

Showing 8 of 10 total issues

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

      def convert_codeblock(el, opts)
        show_whitespace = el.attr['class'].to_s =~ /\bshow-whitespaces\b/
        lang = extract_code_language(el.attr)

        if @options[:syntax_highlighter] == :minted &&
Severity: Minor
Found in lib/cheepub/converter/cheelatex.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_params has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def apply_params(params)
        @maker.title = params[:title]
        add_creator(params[:author])
        parse_creator(params[:creator])
        ##@maker.language = params[:language] || 'ja'
Severity: Minor
Found in lib/cheepub/generator/latex.rb - About 1 hr to fix

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

          def convert_img(el, opts)
            line = el.options[:location]
            angle = @options[:page_direction] == "rtl" ? 90 : 0
            if el.attr['src'] =~ /^(https?|ftps?):\/\//
              warning("Cannot include non-local image#{line ? " (line #{line})" : ''}")
    Severity: Minor
    Found in lib/cheepub/converter/cheelatex.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 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def execute
          params = {}
          if config
            params = YAML.safe_load(config).symbolize_keys!
          end
    Severity: Minor
    Found in lib/cheepub/cli.rb - About 1 hr to fix

      Method apply_params has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def apply_params(params)
              @book.identifier = params[:id] || "urn:uuid:#{SecureRandom.uuid}"
              @book.title = params[:title]
              @book.add_creator(params[:author])
              parse_creator(params[:creator])
      Severity: Minor
      Found in lib/cheepub/generator/epub.rb - About 1 hr to fix

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

              def apply_params(params)
                @maker.title = params[:title]
                add_creator(params[:author])
                parse_creator(params[:creator])
                ##@maker.language = params[:language] || 'ja'
        Severity: Minor
        Found in lib/cheepub/generator/latex.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 interpolate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def interpolate(str, values)
              return "" if str.nil?
              str.gsub(INTERPOLATION_PATTERN) do |match|
                if match == '%%'
                  '%'
        Severity: Minor
        Found in lib/cheepub/i18n.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 deep_merge! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def deep_merge!(other_hash, &block)
                merge!(other_hash) do |key, this_val, other_val|
                  if this_val.is_a?(Hash) && other_val.is_a?(Hash)
                    this_val.dup.deep_merge!(other_val, &block)
                  elsif block_given?
        Severity: Minor
        Found in lib/cheepub/ext_hash.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

        Severity
        Category
        Status
        Source
        Language