calismamasam/calismamasam.com

View on GitHub

Showing 22 of 22 total issues

Method index has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    @product_categories = ProductCategory.roots.order(title: :asc)
    @post_category = Category.friendly.find(params[:post_category_id]) unless params[:post_category_id].nil?

    if params[:id]
Severity: Minor
Found in app/controllers/stats_controller.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 call has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def call
      # Get products
      category_ids = context.parent_product_category ? context.parent_product_category.subtree.map(&:subtree_ids).flatten.uniq : nil
      products = Product.where(category_id: category_ids)
      if context.post_category.present?
Severity: Minor
Found in app/interactors/stats_interactors/get_chart_data.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 find_for_oauth has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def self.find_for_oauth(auth, signed_in_resource = nil)
    identity = Identity.find_for_oauth(auth)
    user = signed_in_resource ? signed_in_resource : identity.user
    if user.nil?
      email_is_verified = auth.info.email && (auth.info.verified || auth.info.verified_email)
Severity: Minor
Found in app/models/user.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 call has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def call
      context.fail!(error: 'Product not found') unless context.product.present?
      product = context.product

      records = ActiveRecord::Base.connection.execute(raw_query(product.id))
Severity: Minor
Found in app/interactors/stats_interactors/get_product_chart_data.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 call has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def call
      # Get products
      category_ids = context.parent_product_category ? context.parent_product_category.subtree.map(&:subtree_ids).flatten.uniq : nil
      products = Product.where(category_id: category_ids)
      if context.post_category.present?
Severity: Minor
Found in app/interactors/stats_interactors/get_chart_data.rb - About 1 hr to fix

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

      def update
        respond_to do |format|
          update_method = user_params[:password].present? ? 'update_with_password' : 'update'
          if @user.send(update_method, user_params)
            user_params[:subscriber_agreement] == '1' ? @user.add_as_subscriber : @user.opt_out_from_subscription
    Severity: Minor
    Found in app/controllers/profiles_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 finish_signup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def finish_signup
        if request.patch? && @user.present? && params[:user] && params[:user][:email]
          if @user.update(sign_up_params)
            sign_up_params[:subscriber_agreement] == '1' ? @user.add_as_subscriber : @user.opt_out_from_subscription
            bypass_sign_in(@user)
    Severity: Minor
    Found in app/controllers/users_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 index has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def index
        @product_categories = ProductCategory.roots.order(title: :asc)
        @post_category = Category.friendly.find(params[:post_category_id]) unless params[:post_category_id].nil?
    
        if params[:id]
    Severity: Minor
    Found in app/controllers/stats_controller.rb - About 1 hr to fix

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

        def create
          @result = false
          @message = nil
          subscriber = Subscriber.find_by(email: subscriber_params[:email])
          if subscriber
      Severity: Minor
      Found in app/controllers/subscribers_controller.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 set_facets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_facets
            @facets.keys.each do |k|
              @facets['Kategoriler'] = @facets.delete(k) if k == 'categories'
              @facets['Kullanılan Ekipmanlar'] = @facets.delete(k) if k == 'products'
              @facets['Çalıştığı Şirket'] = @facets.delete(k) if k == 'company'
      Severity: Minor
      Found in app/interactors/search_interactors/search_post.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def call
            post = context.post
            if post.present? && post.decorate.notifiable?
              client = Twitter::REST::Client.new do |config|
                config.consumer_key        = ENV['TWITTER_CONSUMER_KEY']
      Severity: Minor
      Found in app/interactors/post_interactors/notify_twitter.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize(user)
          return unless user
          return if user.role == 'user'
          can :access, :rails_admin
          can :dashboard
      Severity: Minor
      Found in app/models/ability.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 facet_filters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def facet_filters
            filters = []
            filters << "categories:#{@params[:category]}" unless @params[:category].blank?
            filters << "company:#{@params[:company]}" unless @params[:company].blank?
            filters << "products:#{@params[:product]}" unless @params[:product].blank?
      Severity: Minor
      Found in app/interactors/search_interactors/search_post.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 4 locations. Consider refactoring.
      Open

        def like
          @like = @user.like(Post, @post.id)
          @likes_count = @post.likes_count
          @post.touch
      
      
      Severity: Minor
      Found in app/controllers/posts_controller.rb and 3 other locations - About 20 mins to fix
      app/controllers/galleries_controller.rb on lines 10..17
      app/controllers/galleries_controller.rb on lines 21..28
      app/controllers/posts_controller.rb on lines 18..25

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

        def like
          @like = @user.like(Gallery, @gallery.id)
          @likes_count = @gallery.likes_count
          @gallery.touch
      
      
      Severity: Minor
      Found in app/controllers/galleries_controller.rb and 3 other locations - About 20 mins to fix
      app/controllers/galleries_controller.rb on lines 21..28
      app/controllers/posts_controller.rb on lines 7..14
      app/controllers/posts_controller.rb on lines 18..25

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

        has_attached_file :image,
                          styles: { full: '1500x1500>', thumb: '200x200#' },
                          convert_options: {
                            full: '-quality 80 -interlace Plane',
                            thumb: '-quality 80 -interlace Plane'
      Severity: Minor
      Found in app/models/product.rb and 2 other locations - About 20 mins to fix
      app/models/gallery_image.rb on lines 12..22
      app/models/post_image.rb on lines 12..21

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

        has_attached_file :image,
                          styles: { full: '1500x1500>', thumb: '200x200#' },
                          convert_options: {
                            full: '-quality 80 -interlace Plane',
                            thumb: '-quality 80 -interlace Plane'
      Severity: Minor
      Found in app/models/gallery_image.rb and 2 other locations - About 20 mins to fix
      app/models/post_image.rb on lines 12..21
      app/models/product.rb on lines 16..25

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

        has_attached_file :image,
                          styles: { full: '1500x1500>', thumb: '200x200#' },
                          convert_options: {
                            full: '-quality 80 -interlace Plane',
                            thumb: '-quality 80 -interlace Plane'
      Severity: Minor
      Found in app/models/post_image.rb and 2 other locations - About 20 mins to fix
      app/models/gallery_image.rb on lines 12..22
      app/models/product.rb on lines 16..25

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

        def unlike
          @unlike = @user.unlike(Post, @post.id)
          @likes_count = @post.likes_count
          @post.touch
      
      
      Severity: Minor
      Found in app/controllers/posts_controller.rb and 3 other locations - About 20 mins to fix
      app/controllers/galleries_controller.rb on lines 10..17
      app/controllers/galleries_controller.rb on lines 21..28
      app/controllers/posts_controller.rb on lines 7..14

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

        def unlike
          @unlike = @user.unlike(Gallery, @gallery.id)
          @likes_count = @gallery.likes_count
          @gallery.touch
      
      
      Severity: Minor
      Found in app/controllers/galleries_controller.rb and 3 other locations - About 20 mins to fix
      app/controllers/galleries_controller.rb on lines 10..17
      app/controllers/posts_controller.rb on lines 7..14
      app/controllers/posts_controller.rb on lines 18..25

      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