Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Auto-generated by Cimas: Do not edit it manually!
# See https://github.com/metanorma/cimas
inherit_from:
- https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
- .rubocop_todo.yml

inherit_mode:
merge:
- Exclude

# local repo-specific modifications
# ...
plugins:
- rubocop-rspec
- rubocop-performance
- rubocop-rake

AllCops:
TargetRubyVersion: 3.0
323 changes: 323 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,323 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2026-07-27 10:07:24 UTC using RuboCop version 1.88.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 16
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_argument, with_fixed_indentation
Layout/ArgumentAlignment:
Exclude:
- 'lib/postscript/color.rb'
- 'lib/postscript/format_number.rb'
- 'lib/postscript/model/operators/control_flow.rb'
- 'lib/postscript/serializer.rb'
- 'lib/postscript/source/ast_builder.rb'
- 'spec/postscript/color_spec.rb'
- 'spec/postscript/serializer_spec.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_element, with_fixed_indentation
Layout/ArrayAlignment:
Exclude:
- 'lib/postscript/source/lexer.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: IndentationWidth.
Layout/AssignmentIndentation:
Exclude:
- 'lib/postscript/source/ast_builder.rb'

# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleAlignWith.
# SupportedStylesAlignWith: either, start_of_block, start_of_line
Layout/BlockAlignment:
Exclude:
- 'lib/postscript/serializer.rb'
- 'lib/postscript/source/ast_builder.rb'
- 'spec/postscript/format_number_spec.rb'

# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
Layout/BlockEndNewline:
Exclude:
- 'lib/postscript/serializer.rb'
- 'lib/postscript/source/ast_builder.rb'
- 'spec/postscript/format_number_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: IndentationWidth.
Layout/ClosingParenthesisIndentation:
Exclude:
- 'spec/postscript/serializer_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Layout/FirstArgumentIndentation:
Exclude:
- 'spec/postscript/serializer_spec.rb'

# Offense count: 8
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Exclude:
- 'lib/postscript/model/operators/control_flow.rb'
- 'lib/postscript/source/lexer.rb'
- 'spec/postscript/serializer_spec.rb'

# Offense count: 10
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
# SupportedStylesAlignWith: start_of_line, relative_to_receiver
Layout/IndentationWidth:
Exclude:
- 'lib/postscript/serializer.rb'
- 'lib/postscript/source/ast_builder.rb'
- 'spec/postscript/format_number_spec.rb'

# Offense count: 10
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/LineEndStringConcatenationIndentation:
Exclude:
- 'lib/postscript/serializer.rb'

# Offense count: 51
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
# URISchemes: http, https
Layout/LineLength:
Exclude:
- 'lib/postscript/color.rb'
- 'lib/postscript/format_number.rb'
- 'lib/postscript/model/operators/control_flow.rb'
- 'lib/postscript/serializer.rb'
- 'lib/postscript/source/ast_builder.rb'
- 'lib/postscript/source/lexer.rb'
- 'lib/postscript/source/operand_stack.rb'
- 'postscript.gemspec'
- 'spec/postscript/color_spec.rb'
- 'spec/postscript/format_number_spec.rb'
- 'spec/postscript/model/operator_spec.rb'
- 'spec/postscript/serializer_spec.rb'
- 'spec/postscript/source/ast_builder_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineMethodCallBraceLayout:
Exclude:
- 'spec/postscript/serializer_spec.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Layout/MultilineMethodCallIndentation:
Exclude:
- 'lib/postscript/serializer.rb'

# Offense count: 18
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Exclude:
- 'lib/postscript/color.rb'
- 'lib/postscript/format_number.rb'
- 'lib/postscript/model/operators/control_flow.rb'
- 'lib/postscript/serializer.rb'
- 'lib/postscript/source/ast_builder.rb'
- 'lib/postscript/source/lexer.rb'
- 'spec/postscript/color_spec.rb'
- 'spec/postscript/serializer_spec.rb'

# Offense count: 4
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
Lint/DuplicateBranch:
Exclude:
- 'lib/postscript/color.rb'
- 'lib/postscript/serializer.rb'
- 'lib/postscript/source/ast_builder.rb'

# Offense count: 87
# Configuration parameters: AllowedParentClasses.
Lint/MissingSuper:
Exclude:
- 'lib/postscript/model/operators.rb'
- 'lib/postscript/model/operators/arithmetic.rb'
- 'lib/postscript/model/operators/boolean.rb'
- 'lib/postscript/model/operators/color.rb'
- 'lib/postscript/model/operators/container.rb'
- 'lib/postscript/model/operators/control_flow.rb'
- 'lib/postscript/model/operators/dictionary.rb'
- 'lib/postscript/model/operators/font.rb'
- 'lib/postscript/model/operators/graphics_state.rb'
- 'lib/postscript/model/operators/path.rb'
- 'lib/postscript/model/operators/stack.rb'
- 'lib/postscript/model/operators/transformations.rb'

# Offense count: 1
Lint/UselessConstantScoping:
Exclude:
- 'lib/postscript/source/lexer.rb'

# Offense count: 12
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
Metrics/AbcSize:
Exclude:
- 'lib/postscript/color.rb'
- 'lib/postscript/matrix.rb'
- 'lib/postscript/serializer.rb'
- 'lib/postscript/source/ast_builder.rb'
- 'lib/postscript/source/lexer.rb'

# Offense count: 7
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
Metrics/CyclomaticComplexity:
Exclude:
- 'lib/postscript/color.rb'
- 'lib/postscript/serializer.rb'
- 'lib/postscript/source/ast_builder.rb'
- 'lib/postscript/source/lexer.rb'

# Offense count: 17
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 36

# Offense count: 4
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 10

# Offense count: 2
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
Metrics/PerceivedComplexity:
Exclude:
- 'lib/postscript/serializer.rb'
- 'lib/postscript/source/lexer.rb'

# Offense count: 97
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Exclude:
- 'lib/postscript/color.rb'
- 'lib/postscript/matrix.rb'
- 'lib/postscript/model/operators/font.rb'
- 'lib/postscript/model/operators/path.rb'
- 'lib/postscript/model/operators/transformations.rb'
- 'lib/postscript/serializer.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SafeMultiline.
Performance/DeletePrefix:
Exclude:
- 'lib/postscript/source/ast_builder.rb'

# Offense count: 2
RSpec/BeforeAfterAll:
Exclude:
- 'spec/postscript/model/operator_spec.rb'
- 'spec/postscript/model/operators_spec.rb'

# Offense count: 28
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
- 'spec/postscript/color_spec.rb'
- 'spec/postscript/format_number_spec.rb'
- 'spec/postscript/matrix_spec.rb'
- 'spec/postscript/model/operators_spec.rb'

# Offense count: 6
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 14

# Offense count: 1
RSpec/IdenticalEqualityAssertion:
Exclude:
- 'spec/postscript/color_spec.rb'

# Offense count: 26
RSpec/MultipleExpectations:
Max: 6

# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
# FunctionalMethods: let, let!, subject, watch
# AllowedMethods: lambda, proc, it
Style/BlockDelimiters:
Exclude:
- 'lib/postscript/serializer.rb'
- 'lib/postscript/source/ast_builder.rb'
- 'spec/postscript/format_number_spec.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, Mode, AllowedMethods, AllowedPatterns.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
EnforcedStyle: unannotated

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/KeywordArgumentsMerging:
Exclude:
- 'lib/postscript/model/program.rb'

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
Style/MultilineIfModifier:
Exclude:
- 'lib/postscript/format_number.rb'
- 'lib/postscript/serializer.rb'
- 'lib/postscript/source/ast_builder.rb'

# Offense count: 398
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Enabled: false

# Offense count: 5
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
Style/TrailingCommaInArguments:
Exclude:
- 'lib/postscript/color.rb'
- 'spec/postscript/serializer_spec.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
Style/TrailingCommaInHashLiteral:
Exclude:
- 'lib/postscript/matrix.rb'
10 changes: 6 additions & 4 deletions lib/postscript/color.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Color
attr_reader :red, :green, :blue

def self.clamp_byte(value)
Integer === value ? value.clamp(0, 255) : value.to_i.clamp(0, 255)
value.is_a?(Integer) ? value.clamp(0, 255) : value.to_i.clamp(0, 255)
end

def self.scale_unit_to_byte(value)
Expand Down Expand Up @@ -58,9 +58,11 @@ def self.parse(text)
hex = ::Regexp.last_match(1)
new((hex[0] * 2).to_i(16), (hex[1] * 2).to_i(16), (hex[2] * 2).to_i(16))
when /\argb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/
new(::Regexp.last_match(1).to_i, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i)
new(::Regexp.last_match(1).to_i, ::Regexp.last_match(2).to_i,
::Regexp.last_match(3).to_i)
when /\argb\(\s*(\d+)\s+(\d+)\s+(\d+)/
new(::Regexp.last_match(1).to_i, ::Regexp.last_match(2).to_i, ::Regexp.last_match(3).to_i)
new(::Regexp.last_match(1).to_i, ::Regexp.last_match(2).to_i,
::Regexp.last_match(3).to_i)
when "none", "transparent"
nil
else
Expand Down Expand Up @@ -123,7 +125,7 @@ def eql?(other)
"teal" => [0, 128, 128], "lime" => [0, 255, 0],
"aqua" => [0, 255, 255], "fuchsia" => [255, 0, 255],
"orange" => [255, 165, 0], "pink" => [255, 192, 203],
"brown" => [165, 42, 42],
"brown" => [165, 42, 42]
}.freeze

BLACK = Color.new(0, 0, 0).freeze
Expand Down
5 changes: 4 additions & 1 deletion lib/postscript/format_number.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ module FormatNumber
module_function

def call(value)
raise ArgumentError, "non-finite number: #{value.inspect}" unless value.finite?
unless value.finite?
raise ArgumentError,
"non-finite number: #{value.inspect}"
end

normalized = value.zero? ? 0.0 : value
return normalized.to_i.to_s if normalized == normalized.to_i
Expand Down
2 changes: 1 addition & 1 deletion lib/postscript/model/operator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def operator? = true
# output of +findfont+, +add+, +dup+). Carries no semantic value;
# its purpose is to keep the parse-stack shape in sync with the
# runtime stack so chained operators parse cleanly.
class Computed < ::Struct.new(:operator_keyword, keyword_init: true)
Computed = ::Struct.new(:operator_keyword, keyword_init: true) do
def to_s
"<computed:#{operator_keyword}>"
end
Expand Down
Loading