CartoDB/cartodb20

View on GitHub
app/services/carto/bigquery_tilesets_service.rb

Summary

Maintainability
B
7 hrs
Test Coverage

File bigquery_tilesets_service.rb has 253 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'signet/oauth_2/client'
require 'google/apis/bigquery_v2'
require 'date'
require 'json'

Severity: Minor
Found in app/services/carto/bigquery_tilesets_service.rb - About 2 hrs to fix

    Method tileset_metadata_script has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def tileset_metadata_script(dataset_id:, **pagination)
          empty_metadata_query = %{
            SELECT CAST(NULL AS STRING) AS id, CAST(NULL AS STRING) AS metadata LIMIT 0
          }
          %{
    Severity: Minor
    Found in app/services/carto/bigquery_tilesets_service.rb - About 1 hr to fix

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

          def tileset(tileset_id)
            project_id, dataset_id, table_id = tileset_id.split('.')
            resource = "projects/#{project_id}/datasets/#{dataset_id}/tables/#{table_id}"
            iam_policy = @bigquery_api.get_table_iam_policy(resource)
      
      
      Severity: Minor
      Found in app/services/carto/bigquery_tilesets_service.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 initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(user:, connection_id:, project_id:)
            conn = user.connections.find_by(id: connection_id)
            raise Carto::LoadError, 'Missing BigQuery connection' unless conn
            raise Carto::LOadError, 'Invalid BigQuery connection' unless conn.connector == 'bigquery' && conn.complete?
      
      
      Severity: Minor
      Found in app/services/carto/bigquery_tilesets_service.rb - About 1 hr to fix

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

            def initialize(user:, connection_id:, project_id:)
              conn = user.connections.find_by(id: connection_id)
              raise Carto::LoadError, 'Missing BigQuery connection' unless conn
              raise Carto::LOadError, 'Invalid BigQuery connection' unless conn.connector == 'bigquery' && conn.complete?
        
        
        Severity: Minor
        Found in app/services/carto/bigquery_tilesets_service.rb - About 35 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

        There are no issues that match your filters.

        Category
        Status