mohsen-alizadeh/rails-pdate

View on GitHub

Showing 82 of 82 total issues

Cyclomatic complexity for persian_to_gregorian is too high. [7/6]
Open

  def persian_to_gregorian(year,month,day) # :nodoc:
    gg=0
    jy = year - 979
    jm = month - 1
    jd = day - 1
Severity: Minor
Found in lib/rails_pdate/pconvertor.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for gregorian_to_persian is too high. [7/6]
Open

  def gregorian_to_persian(year, month, day) # :nodoc:
    jj=0
    gy = year - 1600
    gm = month - 1
    gd = day - 1
Severity: Minor
Found in lib/rails_pdate/pconvertor.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method persian_to_gregorian has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def persian_to_gregorian(year,month,day) # :nodoc:
    gg=0
    jy = year - 979
    jm = month - 1
    jd = day - 1
Severity: Minor
Found in lib/rails_pdate/pconvertor.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 persian_to_gregorian has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def persian_to_gregorian(year,month,day) # :nodoc:
    gg=0
    jy = year - 979
    jm = month - 1
    jd = day - 1
Severity: Minor
Found in lib/rails_pdate/pconvertor.rb - About 1 hr to fix

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

        format
          .gsub('%Y', '%d' % @year)
          .gsub('%m', '%02d' % @month)
          .gsub('%d', '%02d' % @day)
          .gsub('%C', '%d' % (@year / 100) )
    Severity: Major
    Found in lib/rails_pdate/p_date.rb and 1 other location - About 1 hr to fix
    lib/rails_pdate/p_date_time.rb on lines 15..24

    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

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

        format
            .gsub('%Y', '%d' % @year)
            .gsub('%m', '%02d' % @month)
            .gsub('%d', '%02d' % @day)
            .gsub('%C', '%d' % (@year / 100) )
    Severity: Major
    Found in lib/rails_pdate/p_date_time.rb and 1 other location - About 1 hr to fix
    lib/rails_pdate/p_date.rb on lines 9..18

    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

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

        module DateTime
    
          FORMATS = {
              :short        => '%e %b',
              :long         => '%B %e, %Y',
    Severity: Major
    Found in lib/rails_pdate/formats.rb and 1 other location - About 1 hr to fix
    lib/rails_pdate/formats.rb on lines 26..47

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

    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

        module Date
    
          FORMATS = {
              :short        => '%e %b',
              :long         => '%B %e, %Y',
    Severity: Major
    Found in lib/rails_pdate/formats.rb and 1 other location - About 1 hr to fix
    lib/rails_pdate/formats.rb on lines 3..24

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

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

      def gregorian_to_persian(year, month, day) # :nodoc:
        jj=0
        gy = year - 1600
        gm = month - 1
        gd = day - 1
    Severity: Minor
    Found in lib/rails_pdate/pconvertor.rb - About 1 hr to fix

      Possible XSS Vulnerability in Action View
      Open

          actionview (4.2.6)
      Severity: Minor
      Found in Gemfile.lock by bundler-audit

      Advisory: CVE-2016-6316

      Criticality: Medium

      URL: https://groups.google.com/forum/#!topic/rubyonrails-security/I-VWr034ouk

      Solution: upgrade to ~> 4.2.7.1, ~> 4.2.8, >= 5.0.0.1

      Path Traversal in Sprockets
      Open

          sprockets (3.7.0)
      Severity: Critical
      Found in Gemfile.lock by bundler-audit

      Advisory: CVE-2018-3760

      Criticality: High

      URL: https://groups.google.com/forum/#!topic/ruby-security-ann/2S9Pwz2i16k

      Solution: upgrade to < 3.0.0, >= 2.12.5, < 4.0.0, >= 3.7.2, >= 4.0.0.beta8

      Broken Access Control vulnerability in Active Job
      Open

          activejob (4.2.6)
      Severity: Critical
      Found in Gemfile.lock by bundler-audit

      Advisory: CVE-2018-16476

      Criticality: High

      URL: https://groups.google.com/forum/#!topic/rubyonrails-security/FL4dSdzr2zw

      Solution: upgrade to ~> 4.2.11, ~> 5.0.7.1, ~> 5.1.6.1, ~> 5.1.7, >= 5.2.1.1

      XSS vulnerability in rails-html-sanitizer
      Open

          rails-html-sanitizer (1.0.3)
      Severity: Minor
      Found in Gemfile.lock by bundler-audit

      Advisory: CVE-2018-3741

      URL: https://groups.google.com/d/msg/rubyonrails-security/tP7W3kLc5u4/uDy2Br7xBgAJ

      Solution: upgrade to >= 1.0.4

      Possible information leak / session hijack vulnerability
      Open

          rack (1.6.4)
      Severity: Minor
      Found in Gemfile.lock by bundler-audit

      Advisory: CVE-2019-16782

      Criticality: Medium

      URL: https://github.com/rack/rack/security/advisories/GHSA-hrqr-hxpp-chr3

      Solution: upgrade to ~> 1.6.12, >= 2.0.8

      Possible XSS vulnerability in Rack
      Open

          rack (1.6.4)
      Severity: Minor
      Found in Gemfile.lock by bundler-audit

      Advisory: CVE-2018-16471

      URL: https://groups.google.com/forum/#!topic/ruby-security-ann/NAalCee8n6o

      Solution: upgrade to ~> 1.6.11, >= 2.0.6

      Denial of Service Vulnerability in Action View
      Open

          actionview (4.2.6)
      Severity: Critical
      Found in Gemfile.lock by bundler-audit

      Advisory: CVE-2019-5419

      Criticality: High

      URL: https://groups.google.com/forum/#!topic/rubyonrails-security/GN7w9fFAQeI

      Solution: upgrade to >= 6.0.0.beta3, >= 5.2.2.1, ~> 5.2.2, >= 5.1.6.2, ~> 5.1.6, >= 5.0.7.2, ~> 5.0.7, >= 4.2.11.1, ~> 4.2.11

      Unsafe Query Generation Risk in Active Record
      Open

          activerecord (4.2.6)
      Severity: Critical
      Found in Gemfile.lock by bundler-audit

      Advisory: CVE-2016-6317

      Criticality: High

      URL: https://groups.google.com/forum/#!topic/rubyonrails-security/rgO20zYW33s

      Solution: upgrade to >= 4.2.7.1

      Potential remote code execution of user-provided local names in ActionView
      Open

          actionview (4.2.6)
      Severity: Critical
      Found in Gemfile.lock by bundler-audit

      Advisory: CVE-2020-8163

      Criticality: High

      URL: https://groups.google.com/forum/#!topic/rubyonrails-security/hWuKcHyoKh0

      Solution: upgrade to >= 4.2.11.2

      File Content Disclosure in Action View
      Open

          actionview (4.2.6)
      Severity: Critical
      Found in Gemfile.lock by bundler-audit

      Advisory: CVE-2019-5418

      Criticality: High

      URL: https://groups.google.com/forum/#!topic/rubyonrails-security/pFRKI96Sm8Q

      Solution: upgrade to >= 4.2.11.1, ~> 4.2.11, >= 5.0.7.2, ~> 5.0.7, >= 5.1.6.2, ~> 5.1.6, >= 5.2.2.1, ~> 5.2.2, >= 6.0.0.beta3

      TZInfo relative path traversal vulnerability allows loading of arbitrary files
      Open

          tzinfo (1.2.2)
      Severity: Critical
      Found in Gemfile.lock by bundler-audit

      Advisory: CVE-2022-31163

      Criticality: High

      URL: https://github.com/tzinfo/tzinfo/security/advisories/GHSA-5cm2-9h8c-rvfx

      Solution: upgrade to ~> 0.3.61, >= 1.2.10

      Severity
      Category
      Status
      Source
      Language