Showing 342 of 342 total issues
Class SchemaModification
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class SchemaModification
def initialize(missing_from_map, missing_from_schema, grouped=false)
@missing_from_map = missing_from_map
Function Preview
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
Spontaneous.Preview = (function($, S, $window) {
var dom = S.Dom, goto_id = 0, Ajax = S.Ajax;
var click_param = function() {
return '?__click='+(++goto_id);
};
File revision.rb
has 317 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Spontaneous::Publishing
def self.create_content_table(db, source_table, dest_table_name)
# sqlite doesn't like it if you create a table with no columns
# so hard-code the id column (but don't make it a pk because the
# unique constraint isn't useful at this stage)
Function PageBrowser
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
Spontaneous.PageBrowser = (function($, S) {
var dom = S.Dom
, flattenPageList = function(pageList) {
var pages = []
, comparator = function(a, b) {
- 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
Class PageController
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class PageController < Sinatra::Base
class << self
# We wrap Sinatra's route methods in order to do two things:
# 1. To provide a path of '*' when none is given and
# 2. To register the presence of a handler for each method in order to
Class Image
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class Image < File
autoload :Size, 'spontaneous/field/image/size'
include Spontaneous::Media::Image::Renderable
Similar blocks of code found in 2 locations. Consider refactoring. Open
edited.append(dom.img().attr('src', this.values.local_edited)).click(function() {
this.useValue(this.values.local_edited);
edited.add(original).removeClass('selected');
edited.addClass('selected');
}.bind(this));
- 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 105.
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
Class ScopingMapper
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class ScopingMapper
extend Forwardable
attr_reader :schema, :table
Similar blocks of code found in 2 locations. Consider refactoring. Open
original.append(dom.img().attr('src', this.values.server_original)).click(function() {
this.useValue(this.values.server_original);
edited.add(original).removeClass('selected');
original.addClass('selected');
}.bind(this));
- 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 105.
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 Upload
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
Spontaneous.Upload = (function($, S) {
var upload_id = (new Date()).valueOf();
var Upload = new JS.Class({
initialize: function(manager, target, file, insert_position) {
this.manager = manager;
Function Box
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
Spontaneous.Box = (function($, S) {
var dom = S.Dom;
var Box = new JS.Class(Spontaneous.Content, {
- 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 preview
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
preview: function() {
Spontaneous.UploadManager.register(this);
var self = this
, value = this.currentValue()
, src = value.src
Class Index
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Index
attr_reader :name, :search_types, :site
def initialize(site, name, &definition)
Class FieldPrototype
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class FieldPrototype
attr_reader :owner, :name, :options
def initialize(owner, name, type, options={}, blocks = [], &block)
@owner = owner
Function Dialogue
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
Spontaneous.Dialogue = (function($, S) {
var dom = S.Dom;
var Button = new JS.Class({
- 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 UserAdmin
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
Spontaneous.MetaView.UserAdmin = (function($, S){
var dom = S.Dom, ajax = S.Ajax;
var Level = new JS.Class({
initialize: function(attributes) {
- 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 ConflictedFieldDialogue
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
Spontaneous.ConflictedFieldDialogue = (function($, S) {
var dom = S.Dom, Dialogue = Spontaneous.Dialogue;
var ConflictedFieldDialogue = new JS.Class(Dialogue, {
initialize: function(parent_view, conflicted_fields) {
File content_model.rb
has 299 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'spontaneous/data_mapper/content_model/column_accessors'
require 'spontaneous/data_mapper/content_model/serialization'
require 'spontaneous/data_mapper/content_model/timestamps'
require 'spontaneous/data_mapper/content_model/instance_hooks'
require 'spontaneous/data_mapper/content_model/associations'
Class BoxContents
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class BoxContents < Spontaneous::Output::RenderableArray
attr_reader :box, :schema_id
def initialize(box)
Function BoxContainer
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
Spontaneous.BoxContainer = (function($, S) {
var dom = S.Dom;
var BoxContainer = new JS.Class(S.Views.View, {
- 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"