app/services/carto/bigquery_tilesets_service.rb
File bigquery_tilesets_service.rb
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require 'signet/oauth_2/client'
require 'google/apis/bigquery_v2'
require 'date'
require 'json'
Method tileset_metadata_script
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
}
%{
Method tileset
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
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)
- Read upRead up
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
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?
Method initialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
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?
- Read upRead up
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"