Showing 5 of 13 total issues
File generator.rb
has 340 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "digest"
require "fileutils"
require "pathname"
# Public: Automatically generates TypeScript interfaces for Ruby serializers.
Method infer_type_from
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def infer_type_from(columns_hash, ts_interface)
if type
type
elsif (column = columns_hash[column_name.to_s])
self.multi = true if column.try(:array)
- 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 default_config
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def default_config(root)
Config.new(
# The base serializers that all other serializers extend.
base_serializers: ["BaseSerializer"],
Method as_typescript
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def as_typescript
type_str = if type.respond_to?(:ts_name)
type.ts_name
else
type || TypesFromSerializers.config.unknown_type
- 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 generate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def generate(force: ENV["SERIALIZER_TYPES_FORCE"])
@force_generation = force
config.output_dir.rmtree if force && config.output_dir.exist?
if config.namespace
- 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"