mgleon08/slack_neuralyzer

View on GitHub

Showing 92 of 92 total issues

Assignment Branch Condition size for clean_channel_messages is too high. [47.1/15]
Open

      def clean_channel_messages(channel_id, user_id, end_point)
        has_more = true

        while has_more
          res = Slack.public_send(end_point, channel: channel_id, oldest: start_time, latest: end_time)

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method clean_channel_messages has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

      def clean_channel_messages(channel_id, user_id, end_point)
        has_more = true

        while has_more
          res = Slack.public_send(end_point, channel: channel_id, oldest: start_time, latest: end_time)
Severity: Minor
Found in lib/slack_neuralyzer/cleaner/messages.rb - About 4 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 has too many lines. [24/10]
Open

      def clean_channel_messages(channel_id, user_id, end_point)
        has_more = true

        while has_more
          res = Slack.public_send(end_point, channel: channel_id, oldest: start_time, latest: end_time)

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for get_channel_id is too high. [29.83/15]
Open

      def get_channel_id
        if args.channel
          @channel_type = 'channel'
          channel_id    = dict.find_channel_id(args.channel)
        elsif args.direct

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for clean_channel_file is too high. [25.71/15]
Open

      def clean_channel_file(channel_id, user_id)
        page, total_page = 0, nil
        until page == total_page
          page += 1
          res = Slack.files_list(page: page, channel: channel_id, types: args.file, ts_from: start_time, ts_to: end_time)

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Cyclomatic complexity for clean_channel_messages is too high. [13/6]
Open

      def clean_channel_messages(channel_id, user_id, end_point)
        has_more = true

        while has_more
          res = Slack.public_send(end_point, channel: channel_id, oldest: start_time, latest: end_time)

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for run is too high. [22.2/15]
Open

    def run
      logger.info "Running slack_neuralyzer v#{SlackNeuralyzer::VERSION}\n"
      sleep(1)
      if args.show
        puts dict.show_all_channels
Severity: Minor
Found in lib/slack_neuralyzer/cli.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Perceived complexity for clean_channel_messages is too high. [13/7]
Open

      def clean_channel_messages(channel_id, user_id, end_point)
        has_more = true

        while has_more
          res = Slack.public_send(end_point, channel: channel_id, oldest: start_time, latest: end_time)

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Method has too many lines. [16/10]
Open

      def get_channel_id
        if args.channel
          @channel_type = 'channel'
          channel_id    = dict.find_channel_id(args.channel)
        elsif args.direct

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for show_all_channels is too high. [20.02/15]
Open

    def show_all_channels
      text = ''
      text << light_blue("All user direct:\n")
      text << list_names(users)
      text << light_blue("\nAll channels (public):\n")
Severity: Minor
Found in lib/slack_neuralyzer/dict.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for delete_file is too high. [19.26/15]
Open

      def delete_file(file)
        file_time = time_format(file['timestamp'])
        file_url  = light_magenta("(#{file['permalink']})")
        delete    = delete_format
        Slack.files_delete(file: file['id']) if args.execute

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [14/10]
Open

      def clean_channel_file(channel_id, user_id)
        page, total_page = 0, nil
        until page == total_page
          page += 1
          res = Slack.files_list(page: page, channel: channel_id, types: args.file, ts_from: start_time, ts_to: end_time)

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for clean_channel_file is too high. [7/6]
Open

      def clean_channel_file(channel_id, user_id)
        page, total_page = 0, nil
        until page == total_page
          page += 1
          res = Slack.files_list(page: page, channel: channel_id, types: args.file, ts_from: start_time, ts_to: end_time)

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for finish_text is too high. [16.31/15]
Open

      def finish_text(type)
        text = "\n#{light_green(counter)} #{type}(s) in #{current_channel} "
        if args.execute.nil? && counter.nonzero?
          text << 'will be deleted.'
          text << light_red("\nNow, you can rerun the command and use `-e | --execute` to actually delete the #{type}(s).")

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

      def clean_channel_file(channel_id, user_id)
        page, total_page = 0, nil
        until page == total_page
          page += 1
          res = Slack.files_list(page: page, channel: channel_id, types: args.file, ts_from: start_time, ts_to: end_time)
Severity: Minor
Found in lib/slack_neuralyzer/cleaner/files.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

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

    def init_users_dict
      res = Slack.users_list
      raise SlackApi::Errors::ResponseError, res['error'] unless res['ok']
      members = res['members']
      members.each { |member| @users[member['id']] = member['name'] }
Severity: Minor
Found in lib/slack_neuralyzer/dict.rb and 3 other locations - About 30 mins to fix
lib/slack_neuralyzer/dict.rb on lines 79..83
lib/slack_neuralyzer/dict.rb on lines 96..100
lib/slack_neuralyzer/dict.rb on lines 103..107

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

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

    def init_channels_dict
      res = Slack.channels_list
      raise SlackApi::Errors::ResponseError, res['error'] unless res['ok']
      channels = res['channels']
      channels.each { |channel| @channels[channel['id']] = channel['name'] }
Severity: Minor
Found in lib/slack_neuralyzer/dict.rb and 3 other locations - About 30 mins to fix
lib/slack_neuralyzer/dict.rb on lines 72..76
lib/slack_neuralyzer/dict.rb on lines 96..100
lib/slack_neuralyzer/dict.rb on lines 103..107

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

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

    def init_ims_dict
      res = Slack.im_list
      raise SlackApi::Errors::ResponseError, res['error'] unless res['ok']
      ims = res['ims']
      ims.each { |im| @ims[im['id']] = im['user'] }
Severity: Minor
Found in lib/slack_neuralyzer/dict.rb and 3 other locations - About 30 mins to fix
lib/slack_neuralyzer/dict.rb on lines 72..76
lib/slack_neuralyzer/dict.rb on lines 79..83
lib/slack_neuralyzer/dict.rb on lines 103..107

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

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

    def init_mpims_dict
      res = Slack.mpim_list
      raise SlackApi::Errors::ResponseError, res['error'] unless res['ok']
      mpims = res['groups']
      mpims.each { |mpim| @mpims[mpim['id']] = mpim['name'] }
Severity: Minor
Found in lib/slack_neuralyzer/dict.rb and 3 other locations - About 30 mins to fix
lib/slack_neuralyzer/dict.rb on lines 72..76
lib/slack_neuralyzer/dict.rb on lines 79..83
lib/slack_neuralyzer/dict.rb on lines 96..100

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

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

      def get_channel_id
        if args.channel
          @channel_type = 'channel'
          channel_id    = dict.find_channel_id(args.channel)
        elsif args.direct
Severity: Minor
Found in lib/slack_neuralyzer/cleaner/base.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

Severity
Category
Status
Source
Language