assemblymade/coderwall

View on GitHub

Showing 189 of 189 total issues

Method expand has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.expand(audience)
    audience.keys.map(&:to_sym).collect do |target|

      if target == :user_reach
        user = User.find(audience[target])
Severity: Minor
Found in app/structs/audience.rb - About 1 hr to fix

    Method facts has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def facts
        facts = []
    
        profile.positions.each do |position|
          name     = build_name(position)
    Severity: Minor
    Found in app/structs/linked_in_stream.rb - About 1 hr to fix

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

        def user_update_params
          params.require(:user).permit(:about,
                                       :avatar,
                                       :avatar_cache,
                                       :banner,
      Severity: Minor
      Found in app/controllers/users_controller.rb - About 1 hr to fix

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

          def to_indexed_json
            to_public_hash.deep_merge(
              {
                trending_score:        trending_score,
                popular_score:         value_score,
        Severity: Minor
        Found in app/models/protip.rb - About 1 hr to fix

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

            def create
              @user = (params[:user_id] && User.find(params[:user_id])) || current_user
              return head(:forbidden) unless current_user == @user
              if params[:skill][:name] == "skills separated by comma"
                skill_names = []
          Severity: Minor
          Found in app/controllers/skills_controller.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 protip_topic_page_title has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def protip_topic_page_title(topics)
              username = topics.is_a?(Array) ? (topics.size == 1 ? topics.first : nil) : topics
              unless username.nil? or (user = User.find_by_username(username)).blank?
                "Coderwall - Trending Pro tips by #{user.name}"
              else
          Severity: Minor
          Found in app/helpers/protips_helper.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 weekly_digest has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def weekly_digest(username)
              headers['X-Mailgun-Variables'] = {email_type: WEEKLY_DIGEST_EVENT}.to_json
              track_campaign(WEEKLY_DIGEST_EVENT)
          
              @user = User.find_by_username(username)
          Severity: Minor
          Found in app/mailers/weekly_digest_mailer.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 page_title has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def page_title(override_from_haml = nil)
              return override_from_haml unless override_from_haml.blank?
              if viewing_self?
                if @user.pending?
                  "coderwall.com : your profile (in queue)"
          Severity: Minor
          Found in app/helpers/application_helper.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 search has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.search(query_string, country, page, per_page, search_type = :query_and_fetch)
              country = query_string.gsub!(/country:(.+)/, '') && $1 if country.nil?
              query = ''
          
              if query_string.blank? or query_string =~ /:/
          Severity: Minor
          Found in app/models/team.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 upvote_velocity has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def upvote_velocity(since = Time.at(0))
              Rails.logger.ap since if ENV['DEBUG']
          
              us = upvotes_since(since)
              Rails.logger.ap us  if ENV['DEBUG']
          Severity: Minor
          Found in app/models/protip.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 create has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def create
              #FIXME
              raise "OmniAuth returned error #{params[:error]}" unless params[:error].blank?
              if signed_in?
                current_user.apply_oauth(oauth)
          Severity: Minor
          Found in app/controllers/sessions_controller.rb - About 1 hr to fix

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

              $('.event_links a.more').on('click', this.selector, function (e) {
                $(this).siblings('.more.hide').slideToggle();
                e.preventDefault();
              });
            Severity: Major
            Found in app/assets/javascripts/coderwall.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/coderwall.js on lines 76..79

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

            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 show has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def show
                @user = User.find_by_username!(params[:username])
            
                respond_to do |format|
                  format.html do
            Severity: Minor
            Found in app/controllers/users_controller.rb - About 1 hr to fix

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

                $('a.seeMore').on('click', this.selector, function (e) {
                  $(this).siblings('.seeMore').slideDown();
                  e.preventDefault();
                });
              Severity: Major
              Found in app/assets/javascripts/coderwall.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/coderwall.js on lines 122..125

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

              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 perform has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def perform
                  # ArgumentError: Missing host to link to! Please provide the :host parameter, set default_path_options[:host], or set :only_path to true
                  SitemapGenerator::Sitemap.default_host  = 'https://coderwall.com'
                  SitemapGenerator::Sitemap.public_path    = 'tmp/'
                  SitemapGenerator::Sitemap.sitemaps_host = "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com/"
              Severity: Minor
              Found in app/workers/sitemap_refresh_worker.rb - About 1 hr to fix

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

                  def repo_collaborators(owner, name, since=Time.at(0))
                    (@client.collaborators("#{owner}/#{name}", per_page: 100) || []).map do |user|
                      user.except *USER_ATTRIBUTES_TO_IGNORE
                    end
                  rescue Octokit::NotFound => e
                Severity: Major
                Found in app/structs/github_old.rb and 1 other location - About 1 hr to fix
                app/structs/github_old.rb on lines 169..178

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

                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 repo_forks(owner, name, since=Time.at(0))
                    (@client.forks("#{owner}/#{name}", per_page: 100) || []).map do |user|
                      user.except *REPO_ATTRIBUTES_TO_IGNORE
                    end
                  rescue Octokit::NotFound => e
                Severity: Major
                Found in app/structs/github_old.rb and 1 other location - About 1 hr to fix
                app/structs/github_old.rb on lines 158..167

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

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

                  def validate_each(object, attribute, value)
                    raise(ArgumentError, "A regular expression must be supplied as the :format option of the options hash") unless options[:format].nil? or options[:format].is_a?(Regexp)
                    configuration = {message: "is invalid or not responding", format: URI::regexp(%w(http https))}
                    configuration.update(options)
                
                
                Severity: Minor
                Found in app/validators/uri_validator.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 2 locations. Consider refactoring.
                Open

                  def comment_reply(username, commentor_username, comment_id)
                    headers['X-Mailgun-Variables'] = {email_type: NEW_COMMENT_EVENT}.to_json
                    track_campaign("new_comment")
                
                    @commentor = User.find_by_username(commentor_username)
                Severity: Major
                Found in app/mailers/notifier_mailer.rb and 1 other location - About 1 hr to fix
                app/mailers/notifier_mailer.rb on lines 88..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 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

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

                  def new_comment(user_id, commentor_id, comment_id)
                    headers['X-Mailgun-Variables'] = {email_type: NEW_COMMENT_EVENT}.to_json
                    track_campaign("new_comment")
                
                    @commentor = User.find(commentor_id)
                Severity: Major
                Found in app/mailers/notifier_mailer.rb and 1 other location - About 1 hr to fix
                app/mailers/notifier_mailer.rb on lines 102..114

                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

                Severity
                Category
                Status
                Source
                Language