Showing 169 of 169 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
<View
title={i18n.t('views.pickers.assets.title')}
subTitle={this.props.blockLabel || this.props.sectionLabel}
onLeave={this.props.leaveView}
>
- Read upRead up
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 62.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method render_exception
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def render_exception(exception)
::Locomotive.log "[ApplicationError] #{exception.inspect}"
status = (case exception
when ::Mongoid::Errors::DocumentNotFound then 404
- 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 update_select_options
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def update_select_options(options)
return nil if options.blank?
default_locale = field._parent.site.default_locale.to_sym
include_new_options = false
- 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 fetch_file
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.fetch_file(source)
file = nil
if source.is_a?(String) || source.is_a?(Hash) # simple string or drop
source = source['url'] if source.is_a?(Hash)
- 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 build_fullpath
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def build_fullpath
if self.index_or_not_found?
self.site.each_locale { |locale, current| self.fullpath = self.slug }
else
_parent = self.parent # do not hit the database more than once
- 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 underscore_keys
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def underscore_keys
new_hash = {}
self.each_pair do |key, value|
if value.respond_to?(:collect!) # Array
- 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 find_content_type_of_model
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def find_content_type_of_model(content_type)
value = :other
self.class.content_types.each_pair do |type, rules|
rules.each do |rule|
- 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 render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { pageId, iframeLoaded, location } = this.props;
const currentKey = iframeLoaded ? location.pathname : 'startup';
const slideDirection = !iframeLoaded ? 'up' : (location.state || {}).slideDirection || 'up';
const timeout = slideDirection === 'none' ? { enter: 1, exit: 1 } : { enter: 150, exit: 100 };
Function render
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { sectionDefinition } = this.props;
return (
<div className="editor-section-blocks--new" ref={el => this.pickerRef = el}>
Function render
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { setting, getValue, label, handleChange } = this.props;
const value = getValue(null);
const asset = value && typeof(value) === 'object' ? value : { url: value };
Method _metafields_schema_schema
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _metafields_schema_schema
{
'id' => 'http://locomotive.works/schemas/metafields.json',
'definitions' => {
'field' => {
Method to_json
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_json
add_authenticated_header
if get?
add_pagination_header if resource.respond_to?(:total_pages)
Function build
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const build = (pageId, contentEntryId, baseUrl) => {
const _pageId = compact([pageId, contentEntryId]).join('-');
const basePath = `/${_pageId}/content/edit`;
const sectionsPath = `${basePath}/sections`;
- 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 attributes=
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def attributes=(values)
return unless values
@_attributes = values # memoize them for the callbacks
- 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_stamp
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def document_stamp(document)
distance = distance_of_time_in_words_to_now(document.updated_at)
update = document.updated_at && document.updated_at != document.created_at
if account = (document.updated_by || document.created_by)
- 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 as_json
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def as_json(methods = nil)
methods ||= self.getters
{}.tap do |hash|
methods.each do |meth|
_options = self.property_options[meth]
- 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 render
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const TabPane = {
sections: Sections,
settings: Settings,
seo: Seo
Similar blocks of code found in 2 locations. Consider refactoring. Open
<TextInput
label={i18n.t('views.seo.meta_description_label')}
getValue={() => page.meta_description || ''}
handleChange={value => updatePageSetting('meta_description', value)}
/>
- Read upRead up
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 56.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
<TextInput
label={i18n.t('views.seo.title_label')}
getValue={() => page.seo_title || ''}
handleChange={value => updatePageSetting('seo_title', value)}
/>
- Read upRead up
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 56.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function render
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { input, suggestions, loading } = this.state;
const inputProps = {
placeholder: this.props.placeholder,
value: input || '',