octobox/octobox

View on GitHub

Showing 67 of 67 total issues

Function Octobox has 567 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Octobox = (function() {

  var checkSelectAll = function() {
    $(".js-select_all").click();
  };
Severity: Major
Found in app/assets/javascripts/octobox.js - About 2 days to fix

    Function Octobox has a Cognitive Complexity of 111 (exceeds 5 allowed). Consider refactoring.
    Open

    var Octobox = (function() {
    
      var checkSelectAll = function() {
        $(".js-select_all").click();
      };
    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 569 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var Octobox = (function() {
    
      var checkSelectAll = function() {
        $(".js-select_all").click();
      };
    Severity: Major
    Found in app/assets/javascripts/octobox.js - About 1 day to fix

      Class Search has 42 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 5 hrs to fix

        Method results has a Cognitive Complexity of 35 (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

        Class Configurator has 35 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Configurator
            def attr_encyrption_key
              @key ||= begin
                key = ENV['OCTOBOX_ATTRIBUTE_ENCRYPTION_KEY']
        
        
        Severity: Minor
        Found in lib/octobox/configurator.rb - About 4 hrs to fix

          File notifications_helper.rb has 314 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 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 mute = function(ids){
                  var result = confirm("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 419..431

              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 deleteNotifications = function(ids){
                  var result = confirm("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 161..173

              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 Subject has 26 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 NotificationsController has 25 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class NotificationsController < ApplicationController
                
                  skip_before_action :authenticate_user!
                  before_action :authenticate_web_or_api!
                  before_action :find_notification, only: [:star]
                Severity: Minor
                Found in app/controllers/notifications_controller.rb - About 2 hrs to fix

                  Class User has 25 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class User < ApplicationRecord
                    attr_encrypted :access_token, key: Octobox.config.attr_encyrption_key
                    attr_encrypted :personal_access_token, key: Octobox.config.attr_encyrption_key
                    attr_encrypted :app_token, key: Octobox.config.attr_encyrption_key
                  
                  
                  Severity: Minor
                  Found in app/models/user.rb - About 2 hrs to fix

                    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

                    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

                    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 451..457

                    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 {
                            $('#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 470..476

                    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 sync has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def self.sync(remote_subject)
                        subject = Subject.find_or_create_by(url: remote_subject['url'])
                    
                        # webhook payloads don't always have 'repository' info
                        if remote_subject['repository']
                    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 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

                    Severity
                    Category
                    Status
                    Source
                    Language