octobox/octobox

View on GitHub

Showing 69 of 69 total issues

Function setFavicon has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var setFavicon = function(count) {
    if (count !== unread_count) {
      unread_count = count;

      var title = "Octobox";
Severity: Minor
Found in app/assets/javascripts/octobox.js - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        while ( $.inArray(getIdsFromRows(current)[0], ids) > -1 && current.next().length > 0) {
          current = current.next();
        }
    Severity: Major
    Found in app/assets/javascripts/octobox.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/octobox.js on lines 562..564

    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 63.

    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

        while ( $.inArray(getIdsFromRows(current)[0], ids) > -1 && current.prev().length > 0) {
          current = current.prev();
        }
    Severity: Major
    Found in app/assets/javascripts/octobox.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/octobox.js on lines 559..561

    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 63.

    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 results has 34 lines of code (exceeds 25 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 1 hr to fix

      Method current_notifications has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def current_notifications(scope = notifications_for_presentation)
          [:repo, :reason, :type, :unread, :owner, :state, :number, :author, :is_private, :status, :draft].each do |sub_scope|
            next unless params[sub_scope].present?
            # This cast is required due to a bug in type casting
            # TODO: Rails 5.2 was supposed to fix this:
      Severity: Minor
      Found in app/controllers/concerns/notifications_concern.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 sync has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def sync(remote_subject)
          update({
            repository_full_name: extract_full_name_from_remote_subject(remote_subject),
            github_id: remote_subject['id'],
            state: remote_subject['merged_at'].present? ? 'merged' : remote_subject['state'],
      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 download_reviews has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def download_reviews
          return [] unless github_client && pull_request?
          reviews = github_client.get(url + '/reviews', since: comments.order('created_at ASC').last.try(:created_at))
          return [] unless reviews.present?
          reviews.map { |review|
      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 sidebar_filter_link has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def sidebar_filter_link(active:, param:, value:, count: nil, except: nil, link_class: nil, path_params: nil, title: nil)
          css_class = 'nav-item'
          css_class += ' active' if active
          css_class += " #{param}-#{value}"
      
      
      Severity: Minor
      Found in app/helpers/notifications_helper.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 process_notifications has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def process_notifications(notifications)
          return if notifications.blank?
          eager_load_relation = Octobox.config.subjects_enabled? ? [:subject, :repository, :app_installation] : nil
          existing_notifications = user.notifications.includes(eager_load_relation).where(github_id: notifications.map(&:id))
          notifications.each do |notification|
      Severity: Minor
      Found in app/services/download_service.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 expand_comments has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def expand_comments
          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 create has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create
          case event_header
          when 'issues', 'issue_comment'
            SyncSubjectWorker.perform_async_if_configured(payload['issue'])
          when 'pull_request'
      Severity: Minor
      Found in app/controllers/hooks_controller.rb - About 1 hr to fix

        Method apply_plan has 28 lines of code (exceeds 25 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 1 hr to fix

          Method generate has 28 lines of code (exceeds 25 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 1 hr to fix

            Method perform has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def perform(user_id)
                user = User.find_by(id: user_id)
                return unless user.present?
                return unless user.effective_access_token.present?
            
            
            Severity: Minor
            Found in app/workers/sync_notifications_worker.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

            Function enablePopOvers has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              var enablePopOvers = function() {
                var showTimer;
            
                $('[data-toggle="popover"]').popover({ trigger: "manual" , html: true})
                .on("mouseenter", function () {
            Severity: Minor
            Found in app/assets/javascripts/octobox.js - About 1 hr to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                var nextPage = function() {
                  nextPageButton = $(".page-item:last-child .page-link[rel=next]");
                  if (nextPageButton.length) window.location.href = nextPageButton.attr('href');
                }
              Severity: Minor
              Found in app/assets/javascripts/octobox.js and 1 other location - About 55 mins to fix
              app/assets/javascripts/octobox.js on lines 547..550

              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 54.

              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 prevPage = function() {
                  previousPageButton = $(".page-item:first-child .page-link[rel=prev]")
                  if (previousPageButton.length) window.location.href = previousPageButton.attr('href');
                }
              Severity: Minor
              Found in app/assets/javascripts/octobox.js and 1 other location - About 55 mins to fix
              app/assets/javascripts/octobox.js on lines 542..545

              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 54.

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

                def initialize(query)
                  query = query.to_s
                  @operators = {}
              
                  ss = StringScanner.new(query)
              Severity: Minor
              Found in lib/search_parser.rb - About 55 mins 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 process_unread_state has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def process_unread_state(notifications)
                  return if notifications.blank?
              
                  existing_notifications = user.notifications.where(github_id: notifications.map(&:id)).select('id, github_id, unread')
                  notifications.each do |notification|
              Severity: Minor
              Found in app/services/download_service.rb - About 55 mins 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

                var unarchiveSelected = function(){
                  if (getDisplayedRows().length === 0) return;
                  var ids = getIdsFromRows(getMarkedOrCurrentRows());
                  archive(ids, false);
                }
              Severity: Minor
              Found in app/assets/javascripts/octobox.js and 1 other location - About 45 mins to fix
              app/assets/javascripts/octobox.js on lines 212..216

              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 50.

              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

              Severity
              Category
              Status
              Source
              Language