Showing 34 of 44 total issues
Method submit_raw
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def submit_raw(ref = nil)
self.ref(ref) if ref
data['ref'] = @ref
raise NoRefSetException unless @ref
- Read upRead up
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
File prismic.rb
has 351 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'cgi'
require 'net/http'
require 'uri'
require 'json' unless defined?(JSON)
File structured_text.rb
has 313 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Prismic
module Fragments
class StructuredText < Fragment
# Used during the call of {StructuredText#as_html} : blocks are first gathered by groups,
File json_parsers.rb
has 310 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'cgi'
require 'time'
module Prismic
module JsonParser
Method structured_text_parser
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def structured_text_parser(json)
def self.span_parser(span)
case span['type']
when 'em'
Prismic::Fragments::StructuredText::Span::Em.new(span['start'], span['end'])
Class API
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class API
@@warned_create_search_form = false
@@warned_oauth_initiate_url = false
@@warned_oauth_check_token = false
attr_reader :json
Function generateTOC
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function generateTOC() {
if ($('#filecontents').length === 0) return;
var _toc = $('<ol class="top"></ol>');
var show = false;
var toc = _toc;
Method initialize
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
id,
uid,
type,
href,
tags,
Method as_html
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def as_html(link_resolver, html_serializer=nil)
# Defining blocks that deserve grouping, assigning them "group kind" names
block_group = ->(block){
case block
when Block::ListItem
- Read upRead up
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 first_title
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def first_title
# It is impossible to reuse the StructuredText.first_title method, since
# we need to test the highest title across the whole document
title = false
max_level = 6 # any title with a higher level kicks the current one out
- Read upRead up
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 document_parser
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def document_parser(json)
data_json = json['data'].values.first # {"doc_type": data}
# Removing the unknown types + sending a warning, once
data_json.select!{ |_, fragment|
Method submit_raw
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def submit_raw(ref = nil)
self.ref(ref) if ref
data['ref'] = @ref
raise NoRefSetException unless @ref
Method initialize
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(id, uid, type, tags, slug, lang, fragments, broken, target = nil)
Method as_html
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def as_html(link_resolver, html_serializer=nil)
# Defining blocks that deserve grouping, assigning them "group kind" names
block_group = ->(block){
case block
when Block::ListItem
Method as_html
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def as_html(link_resolver=nil, html_serializer=nil)
html = ''
# Getting Hashes of spanning tags to insert, sorted by starting position, and by ending position
start_spans, end_spans = prepare_spans
# Open tags
Method as_html
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def as_html(link_resolver=nil, html_serializer=nil)
html = ''
# Getting Hashes of spanning tags to insert, sorted by starting position, and by ending position
start_spans, end_spans = prepare_spans
# Open tags
- Read upRead up
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 summaryToggle
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function summaryToggle() {
$('.summary_toggle').click(function(e) {
e.preventDefault();
localStorage.summaryCollapsed = $(this).text();
$('.summary_toggle').each(function() {
Method initialize
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(page, results_per_page, results_size, total_results_size, total_pages, next_page, prev_page, results)
Method initialize
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(api, name, fields, form_method, rel, enctype, action)
Method get
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.get(url, access_token=nil, http_client=Prismic::DefaultHTTPClient, api_cache=Prismic::DefaultCache)
data = {}
data['access_token'] = access_token if access_token
cache_key = url + (access_token ? ('#' + access_token) : '')
api_cache.get_or_set(cache_key, nil, 5) {
- Read upRead up
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"