From 9a3131c40916f0c8b79fc1699974245c99882076 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Mon, 10 Jan 2022 10:57:08 -0800 Subject: [PATCH] Add cspell config to fix spellcheck failures Signed-off-by: Tim Smith --- cspell.json | 84 +++++++++++++++++++ dev-doc/README.md | 4 +- lib/chef_apply/action/base.rb | 2 +- lib/chef_apply/action/converge_target.rb | 2 +- .../generate_temp_cookbook/temp_cookbook.rb | 2 +- lib/chef_apply/cli.rb | 2 +- lib/chef_apply/cli/options.rb | 4 +- lib/chef_apply/startup.rb | 8 +- lib/chef_apply/target_host.rb | 4 +- lib/chef_apply/target_resolver.rb | 4 +- lib/chef_apply/text.rb | 2 +- spec/unit/startup_spec.rb | 2 +- spec/unit/target_resolver_spec.rb | 4 +- 13 files changed, 104 insertions(+), 20 deletions(-) create mode 100644 cspell.json diff --git a/cspell.json b/cspell.json new file mode 100644 index 0000000000..c867af1f01 --- /dev/null +++ b/cspell.json @@ -0,0 +1,84 @@ +// cSpell Settings +{ + // Version of the setting file. Always 0.1 + "version": "0.1", + // language - current active spelling language + "language": "en", + "dictionaryDefinitions": [ + { + "name": "chef", + "file": "./chef_dictionary.txt", + "description": "Custom Chef Dictionary" + } + ], + "dictionaries": ["chef"], + // words - list of words to be always considered correct + "words": [ + "MACHINENAME", + "ipaddress", + "mypassword", + "unikitten", + "repos", + "demosite", + "tempfile", + "CHEFTRN", + "CHEFUPL", + "Compat", + "LASTEXITCODE", + "tempdir", + "errid", + "extname", + "ljust", + "converger", + "mktmpdir", + "levenshteinian", + "APPDATA", + "multispinner", + "MKTEMP", + "CHEFLIC", + "CHEFINS", + "CHEFVAL", + "mountpoint", + "uploader", + "trainerrormapper", + "CHEFNET", + "tmpdir", + "CHEFTARG", + "CHEFPOLICY", + "CHEFCCR", + "CHEFRANGE", + "CHEFAPI", + "CHEFMULTI", + "CHEFRMT", + "CHEFINT", + "Alnum", + "succ", + "proto" + ], + // flagWords - list of words to be always considered incorrect + // This is useful for offensive words and common spelling errors. + // For example "hte" should be "the" + "flagWords": [ + "hte" + ], + "ignorePaths": [ + "CHANGELOG.md", + "**/*.gemspec", + "**/Gemfile.lock", + "**/Gemfile", + ".expeditor/**/*", + "**/*.yml", + "**/*.toml", + "**/Berksfile", + "spec/**", + "cspell.json", + "Vagrantfile", + "**/chefignore" + ], + "ignoreRegExpList": [ + // Ignore "'s" at the end of a word. If "Chef" is an accepted word, so is "Chef's". + "/'s\\b/", + // Ignore "'d" at the end of a word. If "dup" is an accepted word, so is "dup'd". + "/'d\\b/" + ] +} diff --git a/dev-doc/README.md b/dev-doc/README.md index c59e000cd6..45ddc24a97 100644 --- a/dev-doc/README.md +++ b/dev-doc/README.md @@ -37,7 +37,7 @@ To suspend a Vagrant machine use bundle exec chef-run ssh://test@ipaddress directory /tmp/foo --password mypassword ``` -**Here is some prerunned use case, and interim statuses that chef-run displays.** +**Here is some pre-run use cases, and interim statuses that chef-run displays.** ```shell bundle exec chef-run ssh://my_user@host1:2222 directory /tmp/foo --identity-file ~/.ssh/id_rsa user test1 action=create @@ -55,7 +55,7 @@ Valid actions are: :nothing, :create, :remove, :modify, :manage, :lock, :unlock For more information, please consult the documentation for this resource: - + ```shell bundle exec chef-run ssh://my_user@host1:2222 directory /tmp/foo --identity-file ~/.ssh/id_rsa user test1 action=remove diff --git a/lib/chef_apply/action/base.rb b/lib/chef_apply/action/base.rb index f27b0bc7bd..a0f52fe2ee 100644 --- a/lib/chef_apply/action/base.rb +++ b/lib/chef_apply/action/base.rb @@ -51,7 +51,7 @@ def run(&block) @error = e end - # Raise outside the block to ensure that the telemetry cpature completes + # Raise outside the block to ensure that the telemetry capture completes raise @error unless @error.nil? end diff --git a/lib/chef_apply/action/converge_target.rb b/lib/chef_apply/action/converge_target.rb index 4a9cc1d1b2..8892214bc1 100644 --- a/lib/chef_apply/action/converge_target.rb +++ b/lib/chef_apply/action/converge_target.rb @@ -197,7 +197,7 @@ def run_chef_cmd(working_dir, config_file, policy) "exit $LASTEXITCODE" else # cd is shell a builtin, so we'll invoke bash. This also means all commands are executed - # with sudo (as long as we are hardcoding our sudo use) + # with sudo (as long as we are hard coding our sudo use) "bash -c 'cd #{working_dir}; /opt/chef/bin/chef-client -z --config #{File.join(working_dir, config_file)} --recipe-url #{File.join(working_dir, policy)}'" end end diff --git a/lib/chef_apply/action/generate_temp_cookbook/temp_cookbook.rb b/lib/chef_apply/action/generate_temp_cookbook/temp_cookbook.rb index 30e03740aa..26d7b60912 100644 --- a/lib/chef_apply/action/generate_temp_cookbook/temp_cookbook.rb +++ b/lib/chef_apply/action/generate_temp_cookbook/temp_cookbook.rb @@ -69,7 +69,7 @@ def from_existing_recipe(existing_recipe_path) def from_resource(resource_type, resource_name, properties) # Generate a cookbook containing a single default recipe with the specified - # resource in it. Incloud the resource type in the cookbook name so hopefully + # resource in it. Include the resource type in the cookbook name so hopefully # this gives us better reporting info in the future. @descriptor = "#{resource_type}[#{resource_name}]" @from = "resource" diff --git a/lib/chef_apply/cli.rb b/lib/chef_apply/cli.rb index ec7ed32137..187f94b71c 100644 --- a/lib/chef_apply/cli.rb +++ b/lib/chef_apply/cli.rb @@ -211,7 +211,7 @@ def install(target_host, reporter) end end - # Runs a GenerateCookbook action based on recipe/resource infoprovided + # Runs a GenerateCookbook action based on recipe/resource info provided # and renders UI updates as the action reports back def generate_temp_cookbook(arguments, reporter) opts = if arguments.length == 1 diff --git a/lib/chef_apply/cli/options.rb b/lib/chef_apply/cli/options.rb index 1478037296..189ab8bcc4 100644 --- a/lib/chef_apply/cli/options.rb +++ b/lib/chef_apply/cli/options.rb @@ -50,7 +50,7 @@ def self.included(klass) # Special note: # config_path is pre-processed in startup.rb, and is shown here only - # for purpoess of rendering help text. + # for the purpose of rendering help text. klass.option :config_path, short: "-c PATH", long: "--config PATH", @@ -138,7 +138,7 @@ def self.included(klass) end # I really don't like that mixlib-cli refers to the parsed command line flags in - # a hash accesed via the `config` method. Thats just such an overloaded word. + # a hash accessed via the `config` method. Thats just such an overloaded word. def parsed_options config end diff --git a/lib/chef_apply/startup.rb b/lib/chef_apply/startup.rb index b9cbd7c134..7ba02cf965 100644 --- a/lib/chef_apply/startup.rb +++ b/lib/chef_apply/startup.rb @@ -43,7 +43,7 @@ def run(enforce_license: false) # Call this every time, so that if we add or change ~/.chef-workstation # directory structure, we can be sure that it exists. Even with a - # custom configuration, the .chef-workstation directory and subdirs + # custom configuration, the .chef-workstation directory and sub-dirs # are required. setup_workstation_user_directories @@ -65,7 +65,7 @@ def run(enforce_license: false) start_chef_apply(enforce_license: enforce_license) # NOTE: Because these exceptions occur outside of the - # CLI handling, they won't be tracked in telemtry. + # CLI handling, they won't be tracked in telemetry. # We can revisit this once the pending error handling rework # is underway. rescue ConfigPathInvalid => e @@ -149,7 +149,7 @@ def setup_workstation_user_directories end def setup_error_handling - # In Ruby 2.5+ threads print out to stdout when they raise an exception. This is an agressive + # In Ruby 2.5+ threads print out to stdout when they raise an exception. This is an aggressive # attempt to ensure debugging information is not lost, but in our case it is not necessary # because we handle all the errors ourself. So we disable this to keep output clean. # See https://ruby-doc.org/core-2.5.0/Thread.html#method-c-report_on_exception @@ -168,7 +168,7 @@ def load_config # Look for a user-supplied config path by manually parsing the option. # Note that we can't use Mixlib::CLI for this. # To ensure that ChefApply::CLI initializes with correct - # option defaults, we need to have configuraton loaded before initializing it. + # option defaults, we need to have configuration loaded before initializing it. def custom_config_path argv.each_with_index do |arg, index| if arg == "--config-path" || arg == "-c" diff --git a/lib/chef_apply/target_host.rb b/lib/chef_apply/target_host.rb index 7135e64f26..b1f6de96ea 100644 --- a/lib/chef_apply/target_host.rb +++ b/lib/chef_apply/target_host.rb @@ -29,7 +29,7 @@ class TargetHost # We're borrowing a page from train here - because setting up a # reliable connection for testing is a multi-step process, # we'll provide this method which instantiates a TargetHost connected - # to a train mock backend. If the family/name provided resolves to a suported + # to a train mock backend. If the family/name provided resolves to a supported # OS, this instance will mix-in the supporting methods for the given platform; # otherwise those methods will raise NotImplementedError. def self.mock_instance(url, family: "unknown", name: "unknown", @@ -183,7 +183,7 @@ def base_os end end - # TODO 2019-01-29 not expose this, it's internal implemenation. Same with #backend. + # TODO 2019-01-29 not expose this, it's internal implementation. Same with #backend. def platform backend.platform end diff --git a/lib/chef_apply/target_resolver.rb b/lib/chef_apply/target_resolver.rb index b73519d90e..32a7216d9a 100644 --- a/lib/chef_apply/target_resolver.rb +++ b/lib/chef_apply/target_resolver.rb @@ -59,7 +59,7 @@ def config_for_target(url) if target =~ /(.*)@(.*)/ inline_credentials = $1 host = $2 - # We'll use a non-greedy match to grab everthinmg up to the first ':' + # We'll use a non-greedy match to grab everything up to the first ':' # as username if there is no :, credentials is just the username if inline_credentials =~ /(.+?):(.*)/ inline_user = $1 @@ -111,7 +111,7 @@ def expand_targets(target) # POSTFIX can contain further ranges itself # This uses a greedy match (.*) to get include every character # up to the last "[" in PREFIX - # $1 - prefix; $2 - x, $3 - y, $4 unproccessed/remaining text + # $1 - prefix; $2 - x, $3 - y, $4 unprocessed/remaining text TARGET_WITH_RANGE = /^(.*)\[([\p{Alnum}]+):([\p{Alnum}]+)\](.*)/.freeze def do_parse(targets, depth = 0) diff --git a/lib/chef_apply/text.rb b/lib/chef_apply/text.rb index f877802103..850eb2dadb 100644 --- a/lib/chef_apply/text.rb +++ b/lib/chef_apply/text.rb @@ -24,7 +24,7 @@ module ChefApply module Text def self._error_table - # Though ther may be several translations, en.yml will be the only one with + # Though there may be several translations, en.yml will be the only one with # error metadata. path = File.join(_translation_path, "errors", "en.yml") raw_yaml = File.read(path) diff --git a/spec/unit/startup_spec.rb b/spec/unit/startup_spec.rb index d0899ced19..04dff00df2 100644 --- a/spec/unit/startup_spec.rb +++ b/spec/unit/startup_spec.rb @@ -271,7 +271,7 @@ end describe "#load_config" do - context "when a custom configuraton path is provided" do + context "when a custom configuration path is provided" do let(:config_path) { nil } it "loads the config at the custom path" do expect(subject).to receive(:custom_config_path).and_return config_path diff --git a/spec/unit/target_resolver_spec.rb b/spec/unit/target_resolver_spec.rb index d9057239a5..703acef2bc 100644 --- a/spec/unit/target_resolver_spec.rb +++ b/spec/unit/target_resolver_spec.rb @@ -356,9 +356,9 @@ context "#prefix_from_target" do context "when no protocol is provided" do - let(:default_protocol) { "badproto" } + let(:default_protocol) { "bad_proto" } it "uses the default from configuration" do - expect(subject.prefix_from_target("host.com")).to eq %w{badproto:// host.com} + expect(subject.prefix_from_target("host.com")).to eq %w{bad_proto:// host.com} end end