xiaohui-zhangxh/editor_js

View on GitHub

Showing 5 of 110 total issues

Method process_ast has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def process_ast(ast, cmr_options)
      ast.walk do |node|
        if node.type == :code_block
          next if node.fence_info == ''

Severity: Minor
Found in lib/common_marker/rouge.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 process_ast has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def process_ast(ast, cmr_options)
      ast.walk do |node|
        if node.type == :code_block
          next if node.fence_info == ''

Severity: Minor
Found in lib/common_marker/rouge.rb - About 1 hr to fix

    Method render_html has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def render_html(text, cmark_options = :DEFAULT, render_options = :UNSAFE, extensions = [], **cmr_options)
    Severity: Minor
    Found in lib/common_marker/rouge.rb - About 35 mins to fix

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

          def valid?
            return @valid if instance_variable_defined?(:@valid)
      
            @valid = JSON::Validator.validate(SCHEMA, @content)
            return false unless @valid
      Severity: Minor
      Found in lib/editor_js/document.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

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

            def render(_options = {})
              file_info = data['file']
              title = data['title']
              extension = file_info['name']&.split('.')&.last
              extension = '' unless EXTENSIONS.key?(extension)
      Severity: Minor
      Found in lib/editor_js/blocks/attaches_block.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