# jeffreytse/jekyll-spaceship

### Showing 18 of 18 total issues

#### Method scan_mathjax_expression has a Cognitive Complexity of 30 (exceeds 15 allowed). Consider refactoring. Open

    def scan_mathjax_expression(doc, &block)
patterns = get_math_patterns()
doc = doc.clone

# remove code, pre, figure nodes
Found in lib/jekyll-spaceship/processors/mathjax-processor.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"

#### Method on_handle_markdown has 50 lines of code (exceeds 30 allowed). Consider refactoring. Open

    def on_handle_markdown(content)
references = {}
content.scan(/\n\s*($(.*)$:\s*(\S+(\s+".*?")?))/) do |match_data|
ref_name = match_data[1]
Found in lib/jekyll-spaceship/processors/table-processor.rb - About 1 hr to fix

#### Method handle_attr_list has a Cognitive Complexity of 24 (exceeds 15 allowed). Consider refactoring. Open

    def handle_attr_list(data)
cell = data.cell
content = cell.inner_html
# inline attribute list(IAL) handler
ial_handler = ->(list) do
Found in lib/jekyll-spaceship/processors/table-processor.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"

#### Method handle_media has 43 lines of code (exceeds 30 allowed). Consider refactoring. Open

    def handle_media(element, data)
host = data[:host]
src = element.get_attribute('src')
title = element.get_attribute('title')
id = data[:id_from] === 'html' ? '()' : data[:id]
Found in lib/jekyll-spaceship/processors/media-processor.rb - About 1 hr to fix

#### Similar blocks of code found in 2 locations. Consider refactoring. Open

    def on_handle_markdown(content)
# match custom mermaid block and code block
syntax = self.config['syntax']
code_name = syntax['code']
custom = syntax['custom'][-2, 2]
Found in lib/jekyll-spaceship/processors/mermaid-processor.rb and 1 other location - About 1 hr to fix
lib/jekyll-spaceship/processors/plantuml-processor.rb on lines 24..40

## Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

## Tuning

This issue has a mass of 57.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

## Refactorings

#### Similar blocks of code found in 2 locations. Consider refactoring. Open

    def on_handle_markdown(content)
# match custom plantuml block and code block
syntax = self.config['syntax']
code_name = syntax['code']
custom = syntax['custom'][-2, 2]
Found in lib/jekyll-spaceship/processors/plantuml-processor.rb and 1 other location - About 1 hr to fix
lib/jekyll-spaceship/processors/mermaid-processor.rb on lines 27..43

## Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

## Tuning

This issue has a mass of 57.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

## Refactorings

#### Method dispatch_html_block has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring. Open

    def self.dispatch_html_block(page)
doc = Nokogiri::HTML(page.output)
doc.css('script').each do |node|
type = Type.html_block_type node['type']
content = node.content
Found in lib/jekyll-spaceship/cores/manager.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"

#### Method dispatch has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring. Open

    def self.dispatch(page, container, event)
# dispatch to each processor
@@_processors.each do |processor|
processor.dispatch page, container, event
break unless processor.next?
Found in lib/jekyll-spaceship/cores/manager.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"

#### Method emoji_filter has 35 lines of code (exceeds 30 allowed). Consider refactoring. Open

    def emoji_filter(content, selector)
# use nokogiri to parse html
doc = Nokogiri::HTML(content)

body = doc.at('body')
Found in lib/jekyll-spaceship/processors/emoji-processor.rb - About 1 hr to fix

#### Method scan_mathjax_expression has 35 lines of code (exceeds 30 allowed). Consider refactoring. Open

    def scan_mathjax_expression(doc, &block)
patterns = get_math_patterns()
doc = doc.clone

# remove code, pre, figure nodes
Found in lib/jekyll-spaceship/processors/mathjax-processor.rb - About 1 hr to fix

#### Method handle_attr_list has 34 lines of code (exceeds 30 allowed). Consider refactoring. Open

    def handle_attr_list(data)
cell = data.cell
content = cell.inner_html
# inline attribute list(IAL) handler
ial_handler = ->(list) do
Found in lib/jekyll-spaceship/processors/table-processor.rb - About 1 hr to fix

#### Method on_handle_html has 32 lines of code (exceeds 30 allowed). Consider refactoring. Open

    def on_handle_html(content)
# use nokogiri to parse html content
doc = Nokogiri::HTML(content)

data = self.table_scope_data
Found in lib/jekyll-spaceship/processors/table-processor.rb - About 1 hr to fix

#### Method handle_media has a Cognitive Complexity of 19 (exceeds 15 allowed). Consider refactoring. Open

    def handle_media(element, data)
host = data[:host]
src = element.get_attribute('src')
title = element.get_attribute('title')
id = data[:id_from] === 'html' ? '()' : data[:id]
Found in lib/jekyll-spaceship/processors/media-processor.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"

#### Method on_handle_markdown has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring. Open

    def on_handle_markdown(content)
references = {}
content.scan(/\n\s*($(.*)$:\s*(\S+(\s+".*?")?))/) do |match_data|
ref_name = match_data[1]
Found in lib/jekyll-spaceship/processors/table-processor.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"

#### Method handle_hash_element has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring. Open

    def handle_hash_element(data)
doc = data[:doc]
element = data[:element]
data = data[:data]


Found in lib/jekyll-spaceship/processors/element-processor.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"

#### Method dispatch has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring. Open

    def dispatch(page, container, event)
@page = page
@handled = false
return unless self.process?
method = "on_#{container}_#{event}"
Found in lib/jekyll-spaceship/cores/processor.rb - About 35 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"

#### Similar blocks of code found in 2 locations. Consider refactoring. Open

    def handle_mermaid_block(pattern, content)
content.scan pattern do |match|
match = match.select { |m| not m.nil? }
block = match[0]
code = match[2]
Found in lib/jekyll-spaceship/processors/mermaid-processor.rb and 1 other location - About 35 mins to fix
lib/jekyll-spaceship/processors/plantuml-processor.rb on lines 43..56

## Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

## Tuning

This issue has a mass of 34.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

## Refactorings

#### Similar blocks of code found in 2 locations. Consider refactoring. Open

    def handle_plantuml_block(pattern, content)
content.scan pattern do |match|
match = match.select { |m| not m.nil? }
block = match[0]
code = match[2]
Found in lib/jekyll-spaceship/processors/plantuml-processor.rb and 1 other location - About 35 mins to fix
lib/jekyll-spaceship/processors/mermaid-processor.rb on lines 46..59

## Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

## Tuning

This issue has a mass of 34.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.