philnash/bitly

View on GitHub

Showing 17 of 17 total issues

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

    class Client
      USER_AGENT = "Ruby Bitly/#{Bitly::VERSION}"

      ##
      # Creates a new Bitly::API::Client, authorized with an OAuth token and
Severity: Minor
Found in lib/bitly/api/client.rb - About 2 hrs to fix

    Method initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize(status:, body:, headers:, request: nil)
            errors = []
            @status = status
            errors << "Status must be a valid HTTP status code. Received #{status}" unless is_status?(status)
            if body.nil? || body.empty?
    Severity: Minor
    Found in lib/bitly/http/response.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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize(uri: , method: "GET", params: {}, headers: {})
            errors = []
            @uri = uri
            errors << "uri must be an object of type URI. Received a #{uri.class}" unless uri.kind_of?(URI)
            @method = method
    Severity: Minor
    Found in lib/bitly/http/request.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 assign_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def assign_attributes(attributes)
            if self.class.respond_to?(:attributes)
              self.class.attributes.each do |attr|
                instance_variable_set("@#{attr}", attributes[attr.to_s]) if attributes[attr.to_s]
              end
    Severity: Minor
    Found in lib/bitly/api/base.rb - About 45 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

          def self.list_referring_domains(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
            bitlink = Bitlink::Utils.normalise_bitlink(bitlink: bitlink)
            list_metrics(
              client: client,
              path: "/bitlinks/#{bitlink}/referring_domains",
    Severity: Minor
    Found in lib/bitly/api/click_metric.rb and 2 other locations - About 40 mins to fix
    lib/bitly/api/click_metric.rb on lines 91..100
    lib/bitly/api/click_metric.rb on lines 119..128

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

    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

          def self.list_referrers(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
            bitlink = Bitlink::Utils.normalise_bitlink(bitlink: bitlink)
            list_metrics(
              client: client,
              path: "/bitlinks/#{bitlink}/referrers",
    Severity: Minor
    Found in lib/bitly/api/click_metric.rb and 2 other locations - About 40 mins to fix
    lib/bitly/api/click_metric.rb on lines 119..128
    lib/bitly/api/click_metric.rb on lines 131..140

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

    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

          def self.list_countries_by_bitlink(client:, bitlink:, unit: nil, units: nil, size: nil, unit_reference: nil)
            bitlink = Bitlink::Utils.normalise_bitlink(bitlink: bitlink)
            list_metrics(
              client: client,
              path: "/bitlinks/#{bitlink}/countries",
    Severity: Minor
    Found in lib/bitly/api/click_metric.rb and 2 other locations - About 40 mins to fix
    lib/bitly/api/click_metric.rb on lines 91..100
    lib/bitly/api/click_metric.rb on lines 131..140

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

    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

          def self.list_countries_by_group(client:, group_guid:, unit: nil, units: nil, size: nil, unit_reference: nil)
            list_metrics(
              client: client,
              path: "/groups/#{group_guid}/countries",
              unit: unit,
    Severity: Minor
    Found in lib/bitly/api/click_metric.rb and 1 other location - About 25 mins to fix
    lib/bitly/api/click_metric.rb on lines 53..61

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

    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

          def self.list_referring_networks(client:, group_guid:, unit: nil, units: nil, size: nil, unit_reference: nil)
            list_metrics(
              client: client,
              path: "/groups/#{group_guid}/referring_networks",
              unit: unit,
    Severity: Minor
    Found in lib/bitly/api/click_metric.rb and 1 other location - About 25 mins to fix
    lib/bitly/api/click_metric.rb on lines 80..88

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

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

        def access_token(redirect_uri: nil, code: nil, username: nil, password: nil)
          begin
            if redirect_uri && code
              access_token_from_code(redirect_uri: redirect_uri, code: code)
            elsif username && password
    Severity: Minor
    Found in lib/bitly/oauth.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 2 locations. Consider refactoring.
    Open

          def group_countries(group_guid:, unit: nil, units: nil, size: nil, unit_reference: nil)
            ClickMetric.list_countries_by_group(
              client: self,
              group_guid: group_guid,
              unit: unit,
    Severity: Minor
    Found in lib/bitly/api/client.rb and 1 other location - About 15 mins to fix
    lib/bitly/api/client.rb on lines 502..510

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

    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

          def group_referring_networks(group_guid:, unit: nil, units: nil, size: nil, unit_reference: nil)
            ClickMetric.list_referring_networks(
              client: self,
              group_guid: group_guid,
              unit: unit,
    Severity: Minor
    Found in lib/bitly/api/client.rb and 1 other location - About 15 mins to fix
    lib/bitly/api/client.rb on lines 528..536

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

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

          def link_clicks(unit: nil, units: nil, unit_reference: nil, size: nil)
            LinkClick.list(client: @client, bitlink: id, unit: unit, units: units, unit_reference: unit_reference, size: size)
    Severity: Minor
    Found in lib/bitly/api/bitlink.rb and 4 other locations - About 15 mins to fix
    lib/bitly/api/bitlink.rb on lines 321..322
    lib/bitly/api/bitlink.rb on lines 359..360
    lib/bitly/api/group.rb on lines 182..190
    lib/bitly/api/group.rb on lines 207..215

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

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

          def referring_networks(unit: nil, units: nil, unit_reference: nil, size: nil)
            ClickMetric.list_referring_networks(
              client: @client,
              group_guid: guid,
              unit: unit,
    Severity: Minor
    Found in lib/bitly/api/group.rb and 4 other locations - About 15 mins to fix
    lib/bitly/api/bitlink.rb on lines 321..322
    lib/bitly/api/bitlink.rb on lines 341..342
    lib/bitly/api/bitlink.rb on lines 359..360
    lib/bitly/api/group.rb on lines 207..215

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

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

          def clicks_summary(unit: nil, units: nil, unit_reference: nil, size: nil)
            ClicksSummary.fetch(client: @client, bitlink: id, unit: unit, units: units, unit_reference: unit_reference, size: size)
    Severity: Minor
    Found in lib/bitly/api/bitlink.rb and 4 other locations - About 15 mins to fix
    lib/bitly/api/bitlink.rb on lines 341..342
    lib/bitly/api/bitlink.rb on lines 359..360
    lib/bitly/api/group.rb on lines 182..190
    lib/bitly/api/group.rb on lines 207..215

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

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

          def click_metrics_by_country(unit: nil, units: nil, unit_reference: nil, size: nil)
            ClickMetric.list_countries_by_bitlink(client: @client, bitlink: id, unit: unit, units: units, unit_reference: unit_reference, size: size)
    Severity: Minor
    Found in lib/bitly/api/bitlink.rb and 4 other locations - About 15 mins to fix
    lib/bitly/api/bitlink.rb on lines 321..322
    lib/bitly/api/bitlink.rb on lines 341..342
    lib/bitly/api/group.rb on lines 182..190
    lib/bitly/api/group.rb on lines 207..215

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

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

          def countries(unit: nil, units: nil, unit_reference: nil, size: nil)
            ClickMetric.list_countries_by_group(
              client: @client,
              group_guid: guid,
              unit: unit,
    Severity: Minor
    Found in lib/bitly/api/group.rb and 4 other locations - About 15 mins to fix
    lib/bitly/api/bitlink.rb on lines 321..322
    lib/bitly/api/bitlink.rb on lines 341..342
    lib/bitly/api/bitlink.rb on lines 359..360
    lib/bitly/api/group.rb on lines 182..190

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

    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