Skip to content

Commit

Permalink
chore: rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldtse committed Oct 28, 2024
1 parent a5df4c2 commit f404327
Show file tree
Hide file tree
Showing 77 changed files with 1,378 additions and 1,107 deletions.
64 changes: 64 additions & 0 deletions .rspec_status
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
example_id | status | run_time |
----------------------------------- | ------ | --------------- |
./spec/metaschema_spec.rb[1:1:1:1] | passed | 0.00694 seconds |
./spec/metaschema_spec.rb[1:1:1:2] | passed | 0.00481 seconds |
./spec/metaschema_spec.rb[1:1:2:1] | passed | 0.00441 seconds |
./spec/metaschema_spec.rb[1:1:2:2] | passed | 0.00358 seconds |
./spec/metaschema_spec.rb[1:1:3:1] | passed | 0.0022 seconds |
./spec/metaschema_spec.rb[1:1:3:2] | passed | 0.00179 seconds |
./spec/metaschema_spec.rb[1:1:4:1] | passed | 0.00314 seconds |
./spec/metaschema_spec.rb[1:1:4:2] | passed | 0.00219 seconds |
./spec/metaschema_spec.rb[1:1:5:1] | passed | 0.00289 seconds |
./spec/metaschema_spec.rb[1:1:5:2] | passed | 0.002 seconds |
./spec/metaschema_spec.rb[1:1:6:1] | passed | 0.0042 seconds |
./spec/metaschema_spec.rb[1:1:6:2] | passed | 0.00309 seconds |
./spec/metaschema_spec.rb[1:1:7:1] | passed | 0.00576 seconds |
./spec/metaschema_spec.rb[1:1:7:2] | passed | 0.00391 seconds |
./spec/metaschema_spec.rb[1:1:8:1] | passed | 0.00269 seconds |
./spec/metaschema_spec.rb[1:1:8:2] | passed | 0.00189 seconds |
./spec/metaschema_spec.rb[1:1:9:1] | passed | 0.00346 seconds |
./spec/metaschema_spec.rb[1:1:9:2] | passed | 0.00259 seconds |
./spec/metaschema_spec.rb[1:1:10:1] | passed | 0.00244 seconds |
./spec/metaschema_spec.rb[1:1:10:2] | passed | 0.00228 seconds |
./spec/metaschema_spec.rb[1:1:11:1] | passed | 0.00318 seconds |
./spec/metaschema_spec.rb[1:1:11:2] | passed | 0.00254 seconds |
./spec/metaschema_spec.rb[1:1:12:1] | passed | 0.00298 seconds |
./spec/metaschema_spec.rb[1:1:12:2] | passed | 0.00275 seconds |
./spec/metaschema_spec.rb[1:1:13:1] | passed | 0.00334 seconds |
./spec/metaschema_spec.rb[1:1:13:2] | passed | 0.00253 seconds |
./spec/metaschema_spec.rb[1:1:14:1] | passed | 0.0035 seconds |
./spec/metaschema_spec.rb[1:1:14:2] | passed | 0.00255 seconds |
./spec/metaschema_spec.rb[1:1:15:1] | passed | 0.00547 seconds |
./spec/metaschema_spec.rb[1:1:15:2] | passed | 0.00424 seconds |
./spec/metaschema_spec.rb[1:1:16:1] | passed | 0.00248 seconds |
./spec/metaschema_spec.rb[1:1:16:2] | passed | 0.00201 seconds |
./spec/metaschema_spec.rb[1:1:17:1] | passed | 0.00249 seconds |
./spec/metaschema_spec.rb[1:1:17:2] | passed | 0.00185 seconds |
./spec/metaschema_spec.rb[1:1:18:1] | passed | 0.00229 seconds |
./spec/metaschema_spec.rb[1:1:18:2] | passed | 0.00182 seconds |
./spec/metaschema_spec.rb[1:1:19:1] | passed | 0.00252 seconds |
./spec/metaschema_spec.rb[1:1:19:2] | passed | 0.00183 seconds |
./spec/metaschema_spec.rb[1:1:20:1] | passed | 0.00284 seconds |
./spec/metaschema_spec.rb[1:1:20:2] | passed | 0.00204 seconds |
./spec/metaschema_spec.rb[1:1:21:1] | passed | 0.00755 seconds |
./spec/metaschema_spec.rb[1:1:21:2] | passed | 0.00568 seconds |
./spec/metaschema_spec.rb[1:1:22:1] | passed | 0.00272 seconds |
./spec/metaschema_spec.rb[1:1:22:2] | passed | 0.0018 seconds |
./spec/metaschema_spec.rb[1:1:23:1] | passed | 0.0024 seconds |
./spec/metaschema_spec.rb[1:1:23:2] | passed | 0.00169 seconds |
./spec/metaschema_spec.rb[1:1:24:1] | passed | 0.0039 seconds |
./spec/metaschema_spec.rb[1:1:24:2] | passed | 0.0032 seconds |
./spec/metaschema_spec.rb[1:1:25:1] | passed | 0.00356 seconds |
./spec/metaschema_spec.rb[1:1:25:2] | passed | 0.0026 seconds |
./spec/metaschema_spec.rb[1:1:26:1] | passed | 0.00482 seconds |
./spec/metaschema_spec.rb[1:1:26:2] | passed | 0.00368 seconds |
./spec/metaschema_spec.rb[1:1:27:1] | passed | 0.00508 seconds |
./spec/metaschema_spec.rb[1:1:27:2] | passed | 0.00346 seconds |
./spec/metaschema_spec.rb[1:1:28:1] | passed | 0.00368 seconds |
./spec/metaschema_spec.rb[1:1:28:2] | passed | 0.00311 seconds |
./spec/metaschema_spec.rb[1:1:29:1] | passed | 0.0038 seconds |
./spec/metaschema_spec.rb[1:1:29:2] | passed | 0.00259 seconds |
./spec/metaschema_spec.rb[1:1:30:1] | passed | 0.00279 seconds |
./spec/metaschema_spec.rb[1:1:30:2] | passed | 0.002 seconds |
./spec/metaschema_spec.rb[1:1:31:1] | passed | 0.02414 seconds |
./spec/metaschema_spec.rb[1:1:31:2] | passed | 0.01733 seconds |
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
inherit_from: .rubocop_todo.yml
76 changes: 76 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-10-28 08:35:06 UTC using RuboCop version 1.67.0.
# 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: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: leading, trailing
Layout/DotPosition:
Exclude:
- 'spec/metaschema_spec.rb'

# Offense count: 65
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterMagicComment:
Enabled: false

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

# Offense count: 3
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 44

# Offense count: 66
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false

# Offense count: 65
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: literals, strict
Style/MutableConstant:
Exclude:
- 'split_files.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'spec/metaschema_spec.rb'

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

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArguments:
Exclude:
- 'spec/metaschema_spec.rb'
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

source "https://rubygems.org"
source 'https://rubygems.org'

# Specify your gem's dependencies in metaschema.gemspec
gemspec

gem "rake", "~> 13.0"
gem 'rake', '~> 13.0'

gem "rspec", "~> 3.0"
gem 'rspec', '~> 3.0'

gem "rubocop", "~> 1.21"
gem 'rubocop', '~> 1.21'
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rspec/core/rake_task"
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

require "rubocop/rake_task"
require 'rubocop/rake_task'

RuboCop::RakeTask.new

Expand Down
6 changes: 3 additions & 3 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "metaschema"
require 'bundler/setup'
require 'metaschema'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

require "irb"
require 'irb'
IRB.start(__FILE__)
4 changes: 2 additions & 2 deletions exe/metaschema
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../lib/metaschema"
require_relative "../lib/metaschema/cli"
require_relative '../lib/metaschema'
require_relative '../lib/metaschema/cli'

Metaschema::Cli::Commands.start(ARGV)
8 changes: 4 additions & 4 deletions lib/metaschema.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

require "lutaml/model"
require 'lutaml/model'

Lutaml::Model::Config.configure do |config|
require "lutaml/model/xml_adapter/nokogiri_adapter"
require 'lutaml/model/xml_adapter/nokogiri_adapter'
config.xml_adapter = Lutaml::Model::XmlAdapter::NokogiriAdapter
end

require_relative "metaschema/version"
require_relative "metaschema/root"
require_relative 'metaschema/version'
require_relative 'metaschema/root'

module Metaschema
class Error < StandardError; end
Expand Down
46 changes: 24 additions & 22 deletions lib/metaschema/allowed_value_type.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
require "lutaml/model"
# frozen_string_literal: true

require_relative "anchor_type"
require_relative "code_type"
require_relative "image_type"
require_relative "inline_markup_type"
require_relative "insert_type"
require 'lutaml/model'

require_relative 'anchor_type'
require_relative 'code_type'
require_relative 'image_type'
require_relative 'inline_markup_type'
require_relative 'insert_type'

module Metaschema
class AllowedValueType < Lutaml::Model::Serializable
Expand All @@ -25,24 +27,24 @@ class AllowedValueType < Lutaml::Model::Serializable
attribute :img, ImageType, collection: true

xml do
root "AllowedValueType", mixed: true
namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
root 'AllowedValueType', mixed: true
namespace 'http://csrc.nist.gov/ns/oscal/metaschema/1.0'

map_content to: :content
map_attribute "value", to: :value
map_attribute "deprecated", to: :deprecated
map_element "a", to: :a
map_element "insert", to: :insert
map_element "br", to: :br
map_element "code", to: :code
map_element "em", to: :em
map_element "i", to: :i
map_element "b", to: :b
map_element "strong", to: :strong
map_element "sub", to: :sub
map_element "sup", to: :sup
map_element "q", to: :q
map_element "img", to: :img
map_attribute 'value', to: :value
map_attribute 'deprecated', to: :deprecated
map_element 'a', to: :a
map_element 'insert', to: :insert
map_element 'br', to: :br
map_element 'code', to: :code
map_element 'em', to: :em
map_element 'i', to: :i
map_element 'b', to: :b
map_element 'strong', to: :strong
map_element 'sub', to: :sub
map_element 'sup', to: :sup
map_element 'q', to: :q
map_element 'img', to: :img
end
end
end
40 changes: 21 additions & 19 deletions lib/metaschema/allowed_values_type.rb
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
require "lutaml/model"
# frozen_string_literal: true

require_relative "allowed_value_type"
require_relative "markup_line_datatype"
require_relative "property_type"
require_relative "remarks_type"
require 'lutaml/model'

require_relative 'allowed_value_type'
require_relative 'markup_line_datatype'
require_relative 'property_type'
require_relative 'remarks_type'

module Metaschema
class AllowedValuesType < Lutaml::Model::Serializable
attribute :id, :string
attribute :level, :string, default: -> { "ERROR" }
attribute :allow_other, :string, default: -> { "no" }
attribute :extensible, :string, default: -> { "external" }
attribute :level, :string, default: -> { 'ERROR' }
attribute :allow_other, :string, default: -> { 'no' }
attribute :extensible, :string, default: -> { 'external' }
attribute :formal_name, :string
attribute :description, MarkupLineDatatype
attribute :prop, PropertyType, collection: true
attribute :enum, AllowedValueType, collection: true
attribute :remarks, RemarksType

xml do
root "AllowedValuesType"
namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
root 'AllowedValuesType'
namespace 'http://csrc.nist.gov/ns/oscal/metaschema/1.0'

map_attribute "id", to: :id
map_attribute "level", to: :level
map_attribute "allow-other", to: :allow_other
map_attribute "extensible", to: :extensible
map_element "formal-name", to: :formal_name
map_element "description", to: :description
map_element "prop", to: :prop
map_element "enum", to: :enum
map_element "remarks", to: :remarks
map_attribute 'id', to: :id
map_attribute 'level', to: :level
map_attribute 'allow-other', to: :allow_other
map_attribute 'extensible', to: :extensible
map_element 'formal-name', to: :formal_name
map_element 'description', to: :description
map_element 'prop', to: :prop
map_element 'enum', to: :enum
map_element 'remarks', to: :remarks
end
end
end
36 changes: 19 additions & 17 deletions lib/metaschema/anchor_type.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
require "lutaml/model"
# frozen_string_literal: true

require_relative "code_type"
require_relative "image_type"
require_relative "inline_markup_type"
require 'lutaml/model'

require_relative 'code_type'
require_relative 'image_type'
require_relative 'inline_markup_type'

module Metaschema
class AnchorType < Lutaml::Model::Serializable
Expand All @@ -20,21 +22,21 @@ class AnchorType < Lutaml::Model::Serializable
attribute :img, ImageType, collection: true

xml do
root "anchorType", mixed: true
namespace "http://csrc.nist.gov/ns/oscal/metaschema/1.0"
root 'anchorType', mixed: true
namespace 'http://csrc.nist.gov/ns/oscal/metaschema/1.0'

map_content to: :content
map_attribute "href", to: :href
map_attribute "title", to: :title
map_element "code", to: :code
map_element "em", to: :em
map_element "i", to: :i
map_element "b", to: :b
map_element "strong", to: :strong
map_element "sub", to: :sub
map_element "sup", to: :sup
map_element "q", to: :q
map_element "img", to: :img
map_attribute 'href', to: :href
map_attribute 'title', to: :title
map_element 'code', to: :code
map_element 'em', to: :em
map_element 'i', to: :i
map_element 'b', to: :b
map_element 'strong', to: :strong
map_element 'sub', to: :sub
map_element 'sup', to: :sup
map_element 'q', to: :q
map_element 'img', to: :img
end
end
end
Loading

0 comments on commit f404327

Please sign in to comment.