otvorenesudy/otvorenesudy-api

View on GitHub

Showing 27 of 27 total issues

Method scrape has 136 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.scrape
    begin
      total_courts = 0
      data =
        JSON.parse(
Severity: Major
Found in lib/justice_gov_sk_pages.rb - About 5 hrs to fix

    Class CourtMapper has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class CourtMapper
        def initialize(data)
          @data = data.deep_symbolize_keys
        end
    
    
    Severity: Minor
    Found in app/mappers/info_sud/court_mapper.rb - About 3 hrs to fix

      Function exports has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function (api) {
        var validEnv = ['development', 'test', 'production'];
        var currentEnv = api.env();
        var isDevelopmentEnv = api.env('development');
        var isProductionEnv = api.env('production');
      Severity: Major
      Found in babel.config.js - About 3 hrs to fix

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

            begin
              total_civil_hearings = 0
              data =
                JSON.parse(
                  Curl.get(
        Severity: Major
        Found in lib/justice_gov_sk_pages.rb and 3 other locations - About 2 hrs to fix
        lib/justice_gov_sk_pages.rb on lines 3..32
        lib/justice_gov_sk_pages.rb on lines 34..59
        lib/justice_gov_sk_pages.rb on lines 125..152

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

        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

            begin
              total_judges = 0
              data =
                JSON.parse(
                  Curl.get('https://obcan.justice.sk/pilot/api/ress-isu-service/v1/sudca?page=1&size=50').body_str,
        Severity: Major
        Found in lib/justice_gov_sk_pages.rb and 3 other locations - About 2 hrs to fix
        lib/justice_gov_sk_pages.rb on lines 3..32
        lib/justice_gov_sk_pages.rb on lines 92..123
        lib/justice_gov_sk_pages.rb on lines 125..152

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

        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

            begin
              total_decrees = 0
              data =
                JSON.parse(
                  Curl.get('https://obcan.justice.sk/pilot/api/ress-isu-service/v1/rozhodnutie?page=1&size=50').body_str,
        Severity: Major
        Found in lib/justice_gov_sk_pages.rb and 3 other locations - About 2 hrs to fix
        lib/justice_gov_sk_pages.rb on lines 3..32
        lib/justice_gov_sk_pages.rb on lines 34..59
        lib/justice_gov_sk_pages.rb on lines 92..123

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

        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

            begin
              total_courts = 0
              data =
                JSON.parse(
                  Curl.get(
        Severity: Major
        Found in lib/justice_gov_sk_pages.rb and 3 other locations - About 2 hrs to fix
        lib/justice_gov_sk_pages.rb on lines 34..59
        lib/justice_gov_sk_pages.rb on lines 92..123
        lib/justice_gov_sk_pages.rb on lines 125..152

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

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

            def self.parse(html)
              document = Nokogiri::HTML(html)
              detail = document.css('.detail .right .inner > .content')
              contact = detail.at_css('.contact-address')
              information_center = detail.at_css('.informacne-centrum')
        Severity: Minor
        Found in lib/obcan_justice_sk/courts/resource_parser.rb - About 1 hr to fix

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

            def reconcile_registry_center
              office =
                build_office(
                  'Podateľňa',
                  email: mapper.registry_center_email,
          Severity: Major
          Found in app/reconcilers/court_reconciler.rb and 2 other locations - About 55 mins to fix
          app/reconcilers/court_reconciler.rb on lines 52..66
          app/reconcilers/court_reconciler.rb on lines 86..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 45.

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

            def external_url
              if object.year && object.number
                url =  "http://www.zakonypreludi.sk/zz/#{object.year}-#{object.number}#"
                url << 'p' << object.paragraph if object.paragraph
                url << '-' << object.section   if object.section
          Severity: Minor
          Found in app/serializers/legislation_serializer.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

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

            def reconcile_information_center
              office =
                build_office(
                  'Informačné centrum',
                  email: mapper.information_center_email,
          Severity: Major
          Found in app/reconcilers/court_reconciler.rb and 2 other locations - About 55 mins to fix
          app/reconcilers/court_reconciler.rb on lines 69..83
          app/reconcilers/court_reconciler.rb on lines 86..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 45.

          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

            def reconcile_business_registry_center
              office =
                build_office(
                  'Informačné stredisko obchodného registra',
                  email: mapper.business_registry_center_email,
          Severity: Major
          Found in app/reconcilers/court_reconciler.rb and 2 other locations - About 55 mins to fix
          app/reconcilers/court_reconciler.rb on lines 52..66
          app/reconcilers/court_reconciler.rb on lines 69..83

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

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

            def reconcile_judges
              judgements =
                mapper.judges.map do |name|
                  judge = JudgeFinder.find_by(name: name)
          
          
          Severity: Minor
          Found in app/reconcilers/decree_reconciler.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 reconcile_judges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def reconcile_judges
              reconciler = ->(name, chair:) do
                judge = JudgeFinder.find_by(name: name)
          
                if judge
          Severity: Minor
          Found in app/reconcilers/hearing_reconciler.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 3 locations. Consider refactoring.
          Open

            def reconcile_proposers
              proposers =
                mapper.proposers.map do |name|
                  proposer = Proposer.find_or_initialize_by(name_unprocessed: name, hearing: hearing)
          
          
          Severity: Minor
          Found in app/reconcilers/hearing_reconciler.rb and 2 other locations - About 25 mins to fix
          app/reconcilers/hearing_reconciler.rb on lines 90..100
          app/reconcilers/hearing_reconciler.rb on lines 103..113

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

          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

            def reconcile_opponents
              opponents =
                mapper.opponents.map do |name|
                  opponent = Opponent.find_or_initialize_by(name_unprocessed: name, hearing: hearing)
          
          
          Severity: Minor
          Found in app/reconcilers/hearing_reconciler.rb and 2 other locations - About 25 mins to fix
          app/reconcilers/hearing_reconciler.rb on lines 103..113
          app/reconcilers/hearing_reconciler.rb on lines 116..126

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

          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

            def reconcile_defendants
              defendants =
                mapper.defendants.map do |name|
                  defendant = Defendant.find_or_initialize_by(name_unprocessed: name, hearing: hearing)
          
          
          Severity: Minor
          Found in app/reconcilers/hearing_reconciler.rb and 2 other locations - About 25 mins to fix
          app/reconcilers/hearing_reconciler.rb on lines 90..100
          app/reconcilers/hearing_reconciler.rb on lines 116..126

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

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

              def formattable(attribute, options = {})
                define_method attribute do |pattern = nil|
                  value = read_attribute(attribute)
          
                  return value if !value.nil? && (pattern.nil? || pattern == options[:default])
          Severity: Minor
          Found in app/models/concerns/formattable.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 3 locations. Consider refactoring.
          Open

            def opponents
              return [] unless object.proceeding
              return [] unless object.proceeding.hearings.size > 0
          
              opponents = object.proceeding.hearings.map(&:opponents).flatten.uniq(&:name)
          Severity: Minor
          Found in app/serializers/decree_serializer.rb and 2 other locations - About 25 mins to fix
          app/serializers/decree_serializer.rb on lines 38..44
          app/serializers/decree_serializer.rb on lines 47..53

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

          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

            def proposers
              return [] unless object.proceeding
              return [] unless object.proceeding.hearings.size > 0
          
              proposers = object.proceeding.hearings.map(&:proposers).flatten.uniq(&:name)
          Severity: Minor
          Found in app/serializers/decree_serializer.rb and 2 other locations - About 25 mins to fix
          app/serializers/decree_serializer.rb on lines 47..53
          app/serializers/decree_serializer.rb on lines 56..62

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

          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