octobox/octobox

View on GitHub

Showing 68 of 68 total issues

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

Method function_button has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def function_button(title, octicon, css_class, tooltip, hidden=true)
Severity: Minor
Found in app/helpers/notifications_helper.rb - About 35 mins to fix

    Method update_labels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def update_labels(remote_labels)
        existing_labels = labels.to_a
        remote_labels.each do |l|
          label = labels.find_by_github_id(l['id'])
          if label.nil?
    Severity: Minor
    Found in app/models/subject.rb - About 35 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 sync has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def sync
        if Octobox.background_jobs_enabled?
          current_user.sync_notifications
        else
          current_user.sync_notifications_in_foreground
    Severity: Minor
    Found in app/controllers/notifications_controller.rb - About 35 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

    Function addSearchString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      addSearchString: function(searchQuery) {
        if (!db) {
          return;
        }
        if (searchQuery == null || searchQuery == '') {
    Severity: Minor
    Found in app/assets/javascripts/search_suggestion.js - About 35 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 notification_icon has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def notification_icon(notification)
        subject_type = notification.subject_type
        state = notification.user.try(:github_app_authorized?) ? notification.state : nil
        return 'issue-closed' if subject_type == 'Issue' && state == 'closed'
        return 'git-pull-request-draft' if subject_type == 'PullRequest' && notification.draft?
    Severity: Minor
    Found in app/helpers/notifications_helper.rb - About 35 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 create has a Cognitive Complexity of 7 (exceeds 5 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 35 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 comment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def comment
        subject = current_user.notifications.find(params[:id]).subject
    
        if current_user.can_comment?(subject)
          subject.comment(current_user, params[:comment][:body]) if subject.commentable?
    Severity: Minor
    Found in app/controllers/notifications_controller.rb - About 35 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

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

        $('#notification-thread').data('id') == id ? $('#thread').find('.toggle-star').toggleClass("star-active star-inactive") : null;
    Severity: Minor
    Found in app/assets/javascripts/octobox.js and 1 other location - About 30 mins to fix
    app/assets/javascripts/octobox.js on lines 349..349

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

    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

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

            $('#notification-thread').data('id') == id ? $('#thread').find('.toggle-star').toggleClass("star-active star-inactive") : null;
    Severity: Minor
    Found in app/assets/javascripts/octobox.js and 1 other location - About 30 mins to fix
    app/assets/javascripts/octobox.js on lines 338..338

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

    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

    Avoid too many return statements within this method.
    Open

        return false
    Severity: Major
    Found in app/models/user.rb - About 30 mins to fix

      Method attributes_from_api_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def attributes_from_api_response(api_response)
            attrs = DownloadService::API_ATTRIBUTE_MAP.map do |attr, path|
              value = api_response.to_h.dig(*path)
              value = value.dup if value.frozen?
              value.delete!("\u0000") if value.is_a?(String)
      Severity: Minor
      Found in app/models/notification.rb - About 25 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 can_comment? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def can_comment?(subject)
          return false unless subject.commentable?
          return true if personal_access_token_enabled?
          return true if Octobox.fetch_subject?
          return true if github_app_authorized? && subject.repository && subject.repository.commentable?
      Severity: Minor
      Found in app/models/user.rb - About 25 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 adapter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def adapter
            adapter = if ENV['DATABASE_URL']
                        ENV['DATABASE_URL'].split(":").first
                      elsif ENV['DATABASE']
                        ENV['DATABASE']
      Severity: Minor
      Found in lib/database_config.rb - About 25 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 unarchive_if_updated has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def unarchive_if_updated
          return unless self.archived?
          change = changes['updated_at']
          return unless change
          if self.archived && change[1] > change[0]
      Severity: Minor
      Found in app/models/notification.rb - About 25 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 update_status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_status
          if sha.present?
            remote_status = download_status
            if remote_status.present?
              self.status = assign_status(remote_status)
      Severity: Minor
      Found in app/models/subject.rb - About 25 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 update_subject_in_foreground has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def update_subject_in_foreground(force = false)
              return unless download_subject?
              # skip syncing if the notification was updated around the same time as subject
              return if !force && subject != nil && updated_at - subject.updated_at < 2.seconds
      
      
      Severity: Minor
      Found in lib/octobox/notifications/sync_subject.rb - About 25 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 callback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def callback
          transaction_id = params[:transactionid]
          transaction = Octobox::OpenCollective.load_transaction(transaction_id)
      
          if transaction && transaction["result"] && transaction["result"]["amount"] >= 1000
      Severity: Minor
      Found in app/controllers/open_collective_controller.rb - About 25 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 3 locations. Consider refactoring.
      Open

              scope :exclude_label, ->(label_names) {
                label_names = [label_names] if label_names.is_a?(String)
                joins(:labels).where.not(
                  label_names.map { |label_name| Label.arel_table[:name].matches(label_name) }.reduce(:or)
                )
      Severity: Minor
      Found in lib/octobox/notifications/exclusive_scope.rb and 2 other locations - About 25 mins to fix
      lib/octobox/notifications/exclusive_scope.rb on lines 28..33
      lib/octobox/notifications/exclusive_scope.rb on lines 41..46

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

      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 3 locations. Consider refactoring.
      Open

              scope :exclude_author, ->(author_names)  {
                author_names = [author_names] if author_names.is_a?(String)
                joins(:subject).where.not(
                  author_names.map { |author_name| Subject.arel_table[:author].matches(author_name) }.reduce(:or)
                )
      Severity: Minor
      Found in lib/octobox/notifications/exclusive_scope.rb and 2 other locations - About 25 mins to fix
      lib/octobox/notifications/exclusive_scope.rb on lines 41..46
      lib/octobox/notifications/exclusive_scope.rb on lines 48..53

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

      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