octobox/octobox

View on GitHub

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
Severity: Major
Found in app/assets/javascripts/octobox.js - About 2 days to fix

    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
    Severity: Minor
    Found in app/assets/javascripts/octobox.js - About 2 days to fix

    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
    Severity: Major
    Found in app/assets/javascripts/octobox.js - About 1 day to fix

      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: {})
      Severity: Minor
      Found in app/models/search.rb - About 6 hrs to fix

        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']
        
        
        Severity: Minor
        Found in lib/octobox/configurator.rb - About 6 hrs to fix

          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?
          Severity: Minor
          Found in app/models/search.rb - About 5 hrs to fix

          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',
          Severity: Minor
          Found in app/helpers/notifications_helper.rb - About 3 hrs to fix

            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
            Severity: Minor
            Found in app/models/subject.rb - About 3 hrs to fix

              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
              Severity: Minor
              Found in app/models/notification.rb - About 3 hrs to fix

                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() {
                Severity: Major
                Found in app/assets/javascripts/octobox.js and 1 other location - About 3 hrs to fix
                app/assets/javascripts/octobox.js on lines 175..187

                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

                Further Reading

                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() {
                Severity: Major
                Found in app/assets/javascripts/octobox.js and 1 other location - About 3 hrs to fix
                app/assets/javascripts/octobox.js on lines 444..456

                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

                Further Reading

                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?
                Severity: Minor
                Found in lib/octobox/open_collective.rb - About 3 hrs to fix

                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
                
                
                Severity: Minor
                Found in app/models/user.rb - About 3 hrs to fix

                  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
                  Severity: Minor
                  Found in lib/octobox/changelog.rb - About 2 hrs to fix

                  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
                  
                  
                  Severity: Minor
                  Found in app/models/search.rb - About 2 hrs to fix

                  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)
                  Severity: Major
                  Found in app/assets/javascripts/octobox.js and 1 other location - About 2 hrs to fix
                  app/assets/javascripts/octobox.js on lines 495..501

                  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

                  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 {
                          $('#more-comments').html(data)
                  Severity: Major
                  Found in app/assets/javascripts/octobox.js and 1 other location - About 2 hrs to fix
                  app/assets/javascripts/octobox.js on lines 476..482

                  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

                  Further Reading

                  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)
                  Severity: Minor
                  Found in app/controllers/notifications_controller.rb - About 1 hr to fix

                  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
                  Severity: Minor
                  Found in app/models/subject.rb - About 1 hr to fix

                  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
                      }
                  
                  
                  Severity: Minor
                  Found in lib/page_limiting_octokit_client.rb - About 1 hr to fix

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language