Showing 69 of 69 total issues
Function Octobox
has 589 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Octobox = (function() {
var maybeConfirm = function(message){
if($('body.disable_confirmations').length){
return true
Function Octobox
has a Cognitive Complexity of 116 (exceeds 5 allowed). Consider refactoring. Open
var Octobox = (function() {
var maybeConfirm = function(message){
if($('body.disable_confirmations').length){
return true
- 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 octobox.js
has 591 lines of code (exceeds 250 allowed). Consider refactoring. Open
var Octobox = (function() {
var maybeConfirm = function(message){
if($('body.disable_confirmations').length){
return true
Class Search
has 44 methods (exceeds 20 allowed). Consider refactoring. Open
class Search
attr_accessor :parsed_query
attr_accessor :scope
def self.initialize_for_saved_search(query:, user:, params: {})
Class Configurator
has 44 methods (exceeds 20 allowed). Consider refactoring. Open
class Configurator
def attr_encryption_key
@key ||= begin
key = ENV['OCTOBOX_ATTRIBUTE_ENCRYPTION_KEY']
Method results
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def results
res = scope
res = scope.search_by_subject_title(parsed_query.freetext) if parsed_query.freetext.present?
res = res.repo(repo) if repo.present?
res = res.exclude_repo(exclude_repo) if exclude_repo.present?
- 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 notifications_helper.rb
has 318 lines of code (exceeds 250 allowed). Consider refactoring. Open
module NotificationsHelper
REASON_LABELS = {
'comment' => 'primary',
'author' => 'success',
'state_change' => 'info',
Class Subject
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class Subject < ApplicationRecord
has_many :notifications, foreign_key: :subject_url, primary_key: :url
has_many :labels, dependent: :delete_all
has_many :users, through: :notifications
has_many :comments, dependent: :delete_all
Class Notification
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class Notification < ApplicationRecord
include Octobox::Notifications::InclusiveScope
include Octobox::Notifications::ExclusiveScope
include Octobox::Notifications::SyncSubject
Similar blocks of code found in 2 locations. Consider refactoring. Open
var deleteNotifications = function(ids){
var result = maybeConfirm("Are you sure you want to delete?");
if (result) {
$.post("/notifications/delete_selected" + location.search, {"id[]": ids})
.done(function() {
- 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 104.
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
var mute = function(ids){
var result = maybeConfirm("Are you sure you want to mute?");
if (result) {
$.post( "/notifications/mute_selected" + location.search, { "id[]": ids})
.done(function() {
- 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 104.
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 apply_plan
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def self.apply_plan(subscriber_names, plan_name)
plan = SubscriptionPlan.find_by_name(plan_name)
return Rails.logger.info("n\n\033[32m[#{Time.current}] ERROR -- Could not find plan named #{plan_name}\033[0m\n\n") if plan.nil?
current_subs_purchases = plan.subscription_purchases.where(unit_count: 1) unless plan.nil?
- 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 User
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ApplicationRecord
attr_encrypted :access_token, key: Octobox.config.attr_encryption_key
attr_encrypted :personal_access_token, key: Octobox.config.attr_encryption_key
attr_encrypted :app_token, key: Octobox.config.attr_encryption_key
Method generate
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def generate
puts "Updating the repository"
system("git fetch origin master 2>&1 > /dev/null")
puts "=" * 80
- 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 convert
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def convert(params)
[:starred, :unlabelled, :bot].each do |param|
@parsed_query[param] = ['true'] if params[param].present?
end
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
$.get($(this).attr('href'), function(data){
if (data["error"] != null) {
notify(data["error"], "danger")
} else {
$('#thread').html(data)
- 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 76.
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
$.get($(this).attr('href'), function(data){
if (data["error"] != null) {
notify(data["error"], "danger")
} else {
$('#more-comments').html(data)
- 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 76.
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 show
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def show
scope = notifications_for_presentation.newest
scope = load_and_count_notifications(scope) unless request.xhr?
ids = scope.pluck(:id)
- 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_comments
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def update_comments
remote_comments = download_comments
if pull_request? && remote_comments
remote_comments.concat download_reviews
remote_comments.concat download_review_comments
- 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 paginate
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def paginate(url, options = {})
under_max_results = -> (data, max_results) {
! max_results || ! data.respond_to?(:size) || data.size < max_results
}
- 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"