twitterdev/twitter-ruby-ads-sdk

View on GitHub

Showing 29 of 29 total issues

Method oauth_request has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def oauth_request
      request  = http_request
      consumer = OAuth::Consumer.new(@client.consumer_key, @client.consumer_secret, site: domain)
      token    = OAuth::AccessToken.new(consumer, @client.access_token, @client.access_token_secret)
      request.oauth!(consumer.http, consumer, token)
Severity: Minor
Found in lib/twitter-ads/http/request.rb - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File metric_filtering.rb has 278 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'twitter-ads'
require 'yaml'

module TwitterAds

Severity: Minor
Found in examples/metric_filtering.rb - About 2 hrs to fix

    Class Account has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Account
    
        include TwitterAds::DSL
    
        attr_reader :client
    Severity: Minor
    Found in lib/twitter-ads/account.rb - About 2 hrs to fix

      Method to_params has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

            def to_params
              params = {}
              self.class.properties.each do |name, type|
                value = instance_variable_get("@#{name}") || send(name)
                next if value.nil?
      Severity: Minor
      Found in lib/twitter-ads/resources/dsl.rb - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method oauth_request has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def oauth_request
            request  = http_request
            consumer = OAuth::Consumer.new(@client.consumer_key, @client.consumer_secret, site: domain)
            token    = OAuth::AccessToken.new(consumer, @client.access_token, @client.access_token_secret)
            request.oauth!(consumer.http, consumer, token)
      Severity: Minor
      Found in lib/twitter-ads/http/request.rb - About 1 hr to fix

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

            def filter_placements(metrics, placements)
              # return, nothing to exclude
              return if placements.include?(:all_on_twitter) && placements.include?(:publisher_network)
        
              # remove all TAP-related metrics unless publisher_network
        Severity: Minor
        Found in examples/metric_filtering.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 batch_save has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def batch_save(account, objs)
                resource = self::RESOURCE_BATCH % { account_id: account.id }
        
                json_body = []
        
        
        Severity: Minor
        Found in lib/twitter-ads/resources/batch.rb - About 1 hr to fix

          Method load has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def load(account, card_uris = nil, card_id = nil, with_deleted = nil, opts = {})
                  if (card_uris && card_id) || (card_uris.nil? && card_id.nil?)
                    raise ArgumentError.new('card_uris and card_id are exclusive parameters. ' \
                                       'Please supply one or the other, but not both.')
                  end
          Severity: Minor
          Found in lib/twitter-ads/creative/cards_fetch.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 8 locations. Consider refactoring.
          Open

            class Platform
          
              include TwitterAds::DSL
              include TwitterAds::Resource
          
          
          Severity: Major
          Found in lib/twitter-ads/targeting_criteria/platform.rb and 7 other locations - About 45 mins to fix
          lib/twitter-ads/targeting_criteria/app_store_category.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/conversation.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/interest.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/location.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/network_operator.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_market.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_show.rb on lines 5..20

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

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

            class Conversation
          
              include TwitterAds::DSL
              include TwitterAds::Resource
          
          
          Severity: Major
          Found in lib/twitter-ads/targeting_criteria/conversation.rb and 7 other locations - About 45 mins to fix
          lib/twitter-ads/targeting_criteria/app_store_category.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/interest.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/location.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/network_operator.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/platform.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_market.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_show.rb on lines 5..20

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

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

            class Interest
          
              include TwitterAds::DSL
              include TwitterAds::Resource
          
          
          Severity: Major
          Found in lib/twitter-ads/targeting_criteria/interest.rb and 7 other locations - About 45 mins to fix
          lib/twitter-ads/targeting_criteria/app_store_category.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/conversation.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/location.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/network_operator.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/platform.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_market.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_show.rb on lines 5..20

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

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

            class AppStoreCategory
          
              include TwitterAds::DSL
              include TwitterAds::Resource
          
          
          Severity: Major
          Found in lib/twitter-ads/targeting_criteria/app_store_category.rb and 7 other locations - About 45 mins to fix
          lib/twitter-ads/targeting_criteria/conversation.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/interest.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/location.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/network_operator.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/platform.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_market.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_show.rb on lines 5..20

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

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

            class TVShow
          
              include TwitterAds::DSL
              include TwitterAds::Resource
          
          
          Severity: Major
          Found in lib/twitter-ads/targeting_criteria/tv_show.rb and 7 other locations - About 45 mins to fix
          lib/twitter-ads/targeting_criteria/app_store_category.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/conversation.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/interest.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/location.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/network_operator.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/platform.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_market.rb on lines 5..20

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

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

            class NetworkOperator
          
              include TwitterAds::DSL
              include TwitterAds::Resource
          
          
          Severity: Major
          Found in lib/twitter-ads/targeting_criteria/network_operator.rb and 7 other locations - About 45 mins to fix
          lib/twitter-ads/targeting_criteria/app_store_category.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/conversation.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/interest.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/location.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/platform.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_market.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_show.rb on lines 5..20

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

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

            class Location
          
              include TwitterAds::DSL
              include TwitterAds::Resource
          
          
          Severity: Major
          Found in lib/twitter-ads/targeting_criteria/location.rb and 7 other locations - About 45 mins to fix
          lib/twitter-ads/targeting_criteria/app_store_category.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/conversation.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/interest.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/network_operator.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/platform.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_market.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_show.rb on lines 5..20

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

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

            class TVMarket
          
              include TwitterAds::DSL
              include TwitterAds::Resource
          
          
          Severity: Major
          Found in lib/twitter-ads/targeting_criteria/tv_market.rb and 7 other locations - About 45 mins to fix
          lib/twitter-ads/targeting_criteria/app_store_category.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/conversation.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/interest.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/location.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/network_operator.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/platform.rb on lines 5..20
          lib/twitter-ads/targeting_criteria/tv_show.rb on lines 5..20

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

          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

                def load(account, id, opts = {})
                  params   = { with_deleted: true }.merge!(opts)
                  resource = RESOURCE % { account_id: account.id, id: id }
                  response = Request.new(account.client, :get, resource, params: params).perform
                  new(account).from_response(response.body[:data])
          Severity: Minor
          Found in lib/twitter-ads/campaign/targeting_criteria.rb and 1 other location - About 40 mins to fix
          lib/twitter-ads/campaign/tracking_tags.rb on lines 87..91

          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

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

                def load(account, id, opts = {})
                  params   = { with_deleted: true }.merge!(opts)
                  resource = RESOURCE % { account_id: account.id, id: id }
                  response = Request.new(account.client, :get, resource, params: params).perform
                  new(account).from_response(response.body[:data])
          Severity: Minor
          Found in lib/twitter-ads/campaign/tracking_tags.rb and 1 other location - About 40 mins to fix
          lib/twitter-ads/campaign/targeting_criteria.rb on lines 76..80

          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

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

              def initialize(consumer_key, consumer_secret, access_token, access_token_secret, opts = {})
          Severity: Minor
          Found in lib/twitter-ads/client.rb - About 35 mins to fix

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

                  def load(account, card_uris = nil, card_id = nil, with_deleted = nil, opts = {})
            Severity: Minor
            Found in lib/twitter-ads/creative/cards_fetch.rb - About 35 mins to fix
              Severity
              Category
              Status
              Source
              Language