Showing 261 of 342 total issues
Method setup
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
def self.setup(options = {})
config_level = (SPOT_LOG_LEVEL || Spontaneous.env || :production).to_sym # need this for SPOT_LOG_LEVEL
config = Config[config_level] || Config[:production] # default to a production level
stream = \
if logfile = options[:logfile]
- 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 Page
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Spontaneous.Page = (function($, S) {
var dom = S.Dom, user = S.User;
var Page = new JS.Class(Spontaneous.Content, {
initialize: function(content) {
Function appendEntries
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
appendEntries: function(entries) {
// only use dynamic loading for page boxes
var entry_total = this.entries().length, attached = 0;
if (this.level() === 0) {
var availableHeight = S.ContentArea.height() - entries.position().top;
Function User
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Spontaneous.User = (function($, S) {
var ajax = S.Ajax;
var User = new JS.Class({
initialize: function(user_data) {
Function view
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
view: function() {
var self = this;
var user = this.user;
var wrap = dom.div();
var form = dom.form({method: 'post', action: ajax.request_url('/users/'+ user.get('id'))});
Function update
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
update: function(percent) {
this._indeterminate = false;
percent = Math.max(0.1, parseFloat(percent)); // always show something...
this._percent = percent;
Method belongs_to_content
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def belongs_to_content(name, opts = {})
opts[:association] = :many_to_one
opts[:dataset_method] = "#{name}_dataset"
opts[:add_method] = "#{name}="
opts[:load_method] = "load_#{opts[:association]}_association".to_sym
Function open
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
open: function(instance) {
if (this._open || !instance) { return; }
this._instance = instance;
instance.manager = this;
$('body').css('overflow', 'hidden');
Function panel
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
panel: function() {
var wrapper = dom.div(['entry-wrap', this.fields_class(), this.alias_class(), this.depth_class(), this.visibility_class(), this.boxes_class()]);
var contents = dom.div('.entry-contents');
var modification = new S.ModificationStatusPanel(this.content);
Method sync_to_revision
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def sync_to_revision(revision, origin=false)
# 'publish' is a lock to make sure the duplication doesn't cross
# page boundaries unless that's necessary (such as in the case
# of a page addition)
publish = origin || !page?
Method validate!
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
def validate!
begin
validate_schema
rescue Spontaneous::SchemaModificationError => e
changes = e.modification
- 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 next
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
next: function() {
if (this.pending.length === 0) {
this.container.className = 'loaded';
this.remove();
Spontaneous.onload();
Method ask_user_details
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def ask_user_details(defaults = {}, users)
attrs = {}
level = nil
width = 14
valid_login = /^[a-z0-9_]{3,}$/
Function test_field_versions
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
test_field_versions: function(target, fields, success, failure) {
var version_data = {}, modified = 0;
for (var i = 0, ii = fields.length; i < ii; i++) {
var field = fields[i], key = '[fields]['+field.schema_id()+']';
if (field.is_modified()) {
Method safe_load
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def safe_load(file, mtime=nil)
reload = mtime && mtime > mtimes[file]
logger.debug "Reloading #{relativize_path(file)}" if reload
Function Services
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Spontaneous.Services = (function($, S) {
var dom = S.Dom;
var instance = new JS.Singleton({
include: S.Properties,
loaded: function(serviceData) {
Function open_uid_editor
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
open_uid_editor: function() {
this.panel.velocity({'height': '+=14'}, { duration: 200, complete: function() {
var view = $('h3', this.panel), edit = $('.edit', this.panel);
view.hide();
edit.hide().empty();
Method has_many_content
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def has_many_content(name, opts = {})
opts[:association] = :one_to_many
opts[:dataset_method] = "#{name}_dataset"
opts[:load_ps_method] = "load_#{name}_association_prepared_statement".to_sym
opts[:ps_method] = "#{name}_prepared_statement".to_sym
Method schema_validate
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def schema_validate(schema)
if schema_id.nil?
schema.missing_id!(:type, self)
else
# only need to check internal consistency if class already existed
Method open_console
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def open_console
prepare! :console
ARGV.clear
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]