Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appease Rubocop and Mutant, Update README #56

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

wteuber
Copy link
Contributor

@wteuber wteuber commented Sep 14, 2023

This is a refactoring PR - there a no functional changes to the previous version.

  • Update mutant config
  • Update rubocop config
    • Set Rubocop TargetRubyVersion to required_ruby_version defined in gemspec (3.0)
  • Clean up gemspec and Gemfile
  • Update README
  • Remove mutant from default rake task
  • Stop globally suppressing test example outputs
  • Add namespacing to specs

Note: YamlNormalizer::Ext::SortByKey#sort_by_key starts using the keyword argument recursive. This change might affect software components that use YamlNormalizer::Ext::SortByKey.

rake && rake mutant
➜  yaml_normalizer git:(appease_rubocop_and_mutant) rake && rake mutant
################################################
Starting CI spec at 2023-09-15 00:48:51 +0200.
################################################

YamlNormalizer::Ext::Namespaced
  does not modify Ruby Core class Hash
  when extending a Hash instances with Ext::Namespaced
    does not modify the original object
    converts a Hash from a tree structure to a plain key-value

YamlNormalizer::Ext::Nested
  does not modify Ruby Core class Hash
  when extending Hash instances with Ext::Nested
    does not modify the original object
    converts a Hash from a flat key-value pairs to a tree structure
    resets the default_proc
    does not create unknown keys on access

YamlNormalizer::Ext::SortByKey
  does not modify Ruby Core class Hash
  when extending a Hash with Ext::SortByKey
    does not modify the original object
    when keys have different types
      sorts objects by their String representation
    when sorting by keys in first level only
      sorts the Hash but not its nested Hashes
    when sorting by key recursively
      sorts the Hash and all nested Hashes

YamlNormalizer::RakeTask
  defining tasks
    yaml:check
      creates "yaml:check"
      describes "yaml:check"
      creates a named task
    yaml:normalize
      lists "yaml:normalize"
      describes "yaml:normalize"
      creates a named task
  running rake tasks
    running rake task "yaml:check"
      runs with default file configuration
      runs with files = "*.yml"
      raises an error if yaml:check fails
    running rake task "yaml:normalize"
      runs with default options
      runs with configured files

YamlNormalizer::Services::Base
  .new
    accepts arbitrary arguments
  .call
    creates an instance and passes all arguments
    calls method "call" on instance
  #call
    raises NotImplementedError

YamlNormalizer::Services::Check
  param triggered methods
    when called with version param
      prints the version and exits
      prints the version and exits
    when called with help param
      prints the help message and exits
      prints the help message and exits
  .new
    calls super to initialize state of the parent class
  when there are both valid and invalid globbing inputs
    sanitizes list of files before processing
  #call arguments
    without valid globbing inputs
      is expected to equal true
    when YAML file is invalid
      is expected to equal false
      prints "is not a YAML file" message to STDERR
  #call processing
    when single document YAML file is denormalized
      is expected to equal false
      prints out an error message with relative file path
    when single document YAML file is normalized
      is expected to equal true
      prints out a success message with relative file path
    when YAML file contains multiple documents
      passes if YAML file is already normalized

YamlNormalizer::Services::IsYaml
  .new
    calls super to initialize state of the parent class
  #call
    when passing an invalid argument
      is expected to equal false
    when YAML file is invalid
      is expected to equal false
    when YAML file is a scalar
      is expected to equal false
    when YAML file is valid
      is expected to equal true

YamlNormalizer::Services::Normalize
  param triggered methods
    when called with version param
      prints the version and exits
      prints the version and exits
    when called with help param
      prints the help message and exits
      prints the help message and exits
  .new
    calls super to initialize state of the parent class
  when args are partially invalid
    sanitizes the list of files before processing
  #call arguments
    when args don't match any file
      is expected not to raise Exception
      is expected to eql
    when YAML file is invalid
      prints "not a YAML file" message to STDERR
    when using relative path
      processes files with a relative path
  #call processing
    when YAML file contains a single document
      normalizes and updates the yaml file
      prints out a success message with relative file path
    when YAML file contains multiple valid documents and byte order mark
      normalizes the yaml file
    when at least one normalization is not stable
      prints out an error to STDERR

YamlNormalizer
  has a version number

Finished in 0.04167 seconds (files took 0.19165 seconds to load)
62 examples, 0 failures

JSON Coverage report generated for RSpec to /Users/wolfgangteuber/src/github.com/Sage/yaml_normalizer/coverage.         197 / 197 LOC (100.0%) covered.
################################################
Finished in 0.54 seconds.
[PASSED] CI spec
################################################
################################################
Starting CI inch at 2023-09-15 00:48:51 +0200.
################################################

# Seems really good

┃  A  ↑  SpecConfig
┃  A  ↑  #ci_begin_msg
┃  A  ↑  #ci_end_msg
┃  A  ↑  #ci_task
┃  A  ↑  #ci_run
┃  A  ↗  YamlNormalizer::Helpers::ParamParser#parse_params
┃  A  ↗  YamlNormalizer
┃  A  ↗  YamlNormalizer::Services::Base.call
┃  A  ↗  YamlNormalizer::Helpers::Normalize#normalize_yaml
┃  A  ↗  YamlNormalizer::Helpers::ParamParser#print_help
┃  A  ↗  YamlNormalizer::Ext::SortByKey#sort_by_key
┃  A  ↗  YamlNormalizer::Ext::Namespaced#namespaced
┃  A  ↗  YamlNormalizer::Services::Base#initialize
┃  A  ↗  YamlNormalizer::Helpers::ParamParser
┃  A  ↗  YamlNormalizer::Services::Normalize
┃  A  ↗  YamlNormalizer::RakeTask#initialize
┃  A  ↗  YamlNormalizer::Helpers::Normalize
┃  A  ↗  YamlNormalizer::Ext::Nested#nested
┃  A  ↗  YamlNormalizer::Services::IsYaml
┃  A  ↗  YamlNormalizer::RakeTask#files=
┃  A  ↗  YamlNormalizer::Services::Check
┃  A  ↗  YamlNormalizer::Ext::Namespaced
┃  A  ↗  YamlNormalizer::RakeTask#name=
┃  A  ↗  YamlNormalizer::RakeTask#files
┃  A  ↗  YamlNormalizer::Services::Base
┃  A  ↗  YamlNormalizer::Ext::SortByKey
┃  A  ↗  YamlNormalizer::RakeTask#name
┃  A  ↗  YamlNormalizer::Ext::Nested
┃  A  ↗  YamlNormalizer::RakeTask
┃  A  ↗  SpecConfig.data_path
┃  A  ↗  YamlNormalizer::Helpers::ParamParser#print_version
┃  A  ↗  YamlNormalizer::Services::Normalize#files
┃  A  ↗  YamlNormalizer::Services::Check#files
┃  A  ↗  YamlNormalizer::Services::IsYaml#file
┃  A  →  YamlNormalizer::Services::Normalize#initialize
┃  A  →  YamlNormalizer::Services::Check#initialize
┃  A  →  YamlNormalizer::Services::Base#call
┃  A  →  Dummy
┃  A  →  YamlNormalizer::Services::IsYaml#initialize
┃  A  →  YamlNormalizer::Services::Normalize#call
┃  A  →  YamlNormalizer::Services::IsYaml#call
┃  A  →  YamlNormalizer::Services::Check#call
┃  A  ↘  YamlNormalizer::VERSION
┃  A  ↘  YamlNormalizer::Services
┃  A  ↘  YamlNormalizer::Helpers
┃  A  ↘  YamlNormalizer::Ext
################################################
Finished in 0.61 seconds.
[PASSED] CI inch
################################################
################################################
Starting CI flog at 2023-09-15 00:48:52 +0200.
################################################
   233.9: flog total
     5.7: flog/method average

    26.7: main#none
    12.8: YamlNormalizer::Ext::SortByKey#sort_by_key lib/yaml_normalizer/ext/sort_by_key.rb:19-24
    12.8: YamlNormalizer::RakeTask#initialize lib/yaml_normalizer/rake_task.rb:37-46
    11.5: YamlNormalizer::Ext::Namespaced#namespaced lib/yaml_normalizer/ext/namespaced.rb:23-33
    11.4: YamlNormalizer::Services::Normalize#stable? lib/yaml_normalizer/services/normalize.rb:54-58
    11.1: YamlNormalizer::Helpers::Normalize#normalize_yaml lib/yaml_normalizer/helpers/normalize.rb:24-30
    11.1: YamlNormalizer::Helpers::ParamParser#parse_params lib/yaml_normalizer/helpers/param_parser.rb:12-18
    10.6: YamlNormalizer::Services::Normalize#initialize lib/yaml_normalizer/services/normalize.rb:22-27
    10.6: YamlNormalizer::Services::Check#initialize lib/yaml_normalizer/services/check.rb:22-27
     9.4: YamlNormalizer::Services::Normalize#normalize! lib/yaml_normalizer/services/normalize.rb:44-52
     8.2: YamlNormalizer::Services::Check#normalized? lib/yaml_normalizer/services/check.rb:45-58
     7.5: YamlNormalizer::Ext::Nested#nest_key lib/yaml_normalizer/ext/nested.rb:27-35
################################################
Finished in 0.73 seconds.
[PASSED] CI flog
################################################
################################################
Starting CI rubocop at 2023-09-15 00:48:52 +0200.
################################################
Inspecting 33 files
.................................

33 files inspected, no offenses detected
################################################
Finished in 1.66 seconds.
[PASSED] CI rubocop
################################################
################################################
Starting mutant at 2023-09-15 00:48:55 +0200.
################################################
Mutant environment:
Matcher:         #<Mutant::Matcher::Config subjects: [YamlNormalizer*]>
Integration:     rspec
Jobs:            8
Includes:        ["lib"]
Requires:        ["yaml_normalizer"]
Operators:       light
Subjects:        30
All-Tests:       62
Available-Tests: 62
Selected-Tests:  62
Tests/Subject:   2.07 avg
Mutations:       1001
progress: 195/1001 alive: 0 runtime: 1.01s killtime: 4.30s mutations/s: 193.53
progress: 323/1001 alive: 0 runtime: 2.01s killtime: 9.81s mutations/s: 160.70
progress: 437/1001 alive: 0 runtime: 3.01s killtime: 15.33s mutations/s: 145.09
progress: 600/1001 alive: 0 runtime: 4.01s killtime: 20.15s mutations/s: 149.48
progress: 765/1001 alive: 0 runtime: 5.02s killtime: 24.97s mutations/s: 152.50
progress: 901/1001 alive: 0 runtime: 6.02s killtime: 30.22s mutations/s: 149.60
Mutant environment:
Matcher:         #<Mutant::Matcher::Config subjects: [YamlNormalizer*]>
Integration:     rspec
Jobs:            8
Includes:        ["lib"]
Requires:        ["yaml_normalizer"]
Operators:       light
Subjects:        30
All-Tests:       62
Available-Tests: 62
Selected-Tests:  62
Tests/Subject:   2.07 avg
Mutations:       1001
Results:         1001
Kills:           1001
Alive:           0
Timeouts:        0
Runtime:         6.83s
Killtime:        35.19s
Overhead:        -80.60%
Mutations/s:     146.66
Coverage:        100.00%
################################################
Finished in 7.62 seconds.
[PASSED] mutant
################################################

* update mutant config
* update rubocop config
* Set Rubocop TargetRubyVersion to required_ruby_version defined in
gemspec (3.0)
* Clean up gemspec and Gemfile
* Update README
* remove mutant from default rake task
* Stop globally suppressing test example outputs
* Add namespacing to specs
@wteuber wteuber force-pushed the appease_rubocop_and_mutant branch from 2d43ac1 to abd1330 Compare September 14, 2023 22:50
@robkilby
Copy link
Member

Thanks for this @wteuber (hope you're well by the way), I'll get this merged and released as v2.1.0 at some point soon.

@wteuber
Copy link
Contributor Author

wteuber commented Mar 20, 2024

Hey @robkilby, it would be great if you could merge this and release yaml_normalizer v2.1.0 😬

@wteuber
Copy link
Contributor Author

wteuber commented Sep 19, 2024

I know the perfect present for this PR's first anniversary 🎂 😉
Is merging and releasing v2.1.0 still something on your list, @robkilby?
Thanks a lot.

@chrisbarber86 chrisbarber86 merged commit 65d352a into Sage:master Sep 19, 2024
@wteuber wteuber deleted the appease_rubocop_and_mutant branch September 25, 2024 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants