instructure/active_public_resources

View on GitHub

Showing 14 of 14 total issues

Method parse_video has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def parse_video(item)
        video_id = item['id']
        snippet = item['snippet']
        statistics = item['statistics'] ? item['statistics'] : {}
        details = item['contentDetails']
Severity: Minor
Found in lib/active_public_resources/drivers/youtube.rb - About 1 hr to fix

    Method parse_video has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def parse_video(data)
            video = ActivePublicResources::ResponseTypes::Video.new
            video.id            = data['readable_id']
            video.title         = data['title']
            video.description   = data['description']
    Severity: Minor
    Found in lib/active_public_resources/drivers/khan_academy.rb - About 1 hr to fix

      Method parse_video has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def parse_video(data)
              video = ActivePublicResources::ResponseTypes::Video.new
              video.id            = "#{data['uri']}".gsub(/[^\d]/, '').to_i
              video.title         = data['name']
              video.description   = data['description'] || "No description found"
      Severity: Minor
      Found in lib/active_public_resources/drivers/vimeo.rb - About 1 hr to fix

        Method parse_video has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def parse_video(data)
                video = ActivePublicResources::ResponseTypes::Video.new
                video.id            = data['vkey']
                video.title         = data['title']
                video.description   = data['description']
        Severity: Minor
        Found in lib/active_public_resources/drivers/schooltube.rb - About 1 hr to fix

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

            def self.symbolize_keys(hash)
              hash.inject({}){|result, (key, value)|
                new_key = case key
                          when String then key.to_sym
                          else key
          Severity: Minor
          Found in lib/active_public_resources.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 perform_request has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def perform_request(request_criteria)
                  request_criteria.validate_presence!([:query])
                  raise StandardError.new("driver has not been initialized properly") unless @client
          
                  results = HTTParty.get('https://api.vimeo.com/videos',
          Severity: Minor
          Found in lib/active_public_resources/drivers/vimeo.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 parse_quiz has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def parse_quiz(data)
                  quiz = ActivePublicResources::ResponseTypes::Quiz.new
                  quiz.id            = data['id']
                  quiz.title         = data['title']
                  quiz.description   = data['description']
          Severity: Minor
          Found in lib/active_public_resources/drivers/quizlet.rb - About 1 hr to fix

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

                def initialize(args={})
                  args.each do |k,v|
                    if k.to_s == 'sort' && !SORTS.include?(v)
                      raise ArgumentError.new("sort is invalid. Must be in [#{SORTS.join(', ')}]")
                    end
            Severity: Minor
            Found in lib/active_public_resources/request_criteria.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 parse_video has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parse_video(item)
                    video_id = item['id']
                    snippet = item['snippet']
                    statistics = item['statistics'] ? item['statistics'] : {}
                    details = item['contentDetails']
            Severity: Minor
            Found in lib/active_public_resources/drivers/youtube.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

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

                  def perform_request(request_criteria)
                    request_criteria.set_default_criteria!(@default_request_criteria)
                    unless request_criteria.validate_presence(:query) || request_criteria.validate_presence(:channel)
                      raise ArgumentError, "You must specify at least a query or channel"
                    end
            Severity: Minor
            Found in lib/active_public_resources/drivers/youtube.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

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

                  def parse_video(data)
                    video = ActivePublicResources::ResponseTypes::Video.new
                    video.id            = data['vkey']
                    video.title         = data['title']
                    video.description   = data['description']
            Severity: Minor
            Found in lib/active_public_resources/drivers/schooltube.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 parse_video has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parse_video(data)
                    video = ActivePublicResources::ResponseTypes::Video.new
                    video.id            = data['readable_id']
                    video.title         = data['title']
                    video.description   = data['description']
            Severity: Minor
            Found in lib/active_public_resources/drivers/khan_academy.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

                    video.return_types << APR::ReturnTypes::Iframe.new(
                      :driver => DRIVER_NAME,
                      :remote_id => video.id,
                      :url    => "https://player.vimeo.com/video/#{video.id}",
                      :text   => video.title,
            Severity: Minor
            Found in lib/active_public_resources/drivers/vimeo.rb and 1 other location - About 20 mins to fix
            lib/active_public_resources/drivers/schooltube.rb on lines 91..99

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

            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

                    video.return_types << APR::ReturnTypes::Iframe.new(
                      :driver => DRIVER_NAME,
                      :remote_id => video.id,
                      :url    => "https://www.schooltube.com/embed/#{video.id}",
                      :text   => video.title,
            Severity: Minor
            Found in lib/active_public_resources/drivers/schooltube.rb and 1 other location - About 20 mins to fix
            lib/active_public_resources/drivers/vimeo.rb on lines 176..184

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

            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