Skip to content

Commit

Permalink
Merge pull request #203 from chef/linting
Browse files Browse the repository at this point in the history
Add cspell config to fix spellcheck failures
  • Loading branch information
tas50 authored Jan 11, 2022
2 parents 8bc5834 + 9a3131c commit edba5f7
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 20 deletions.
84 changes: 84 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -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/"
]
}
4 changes: 2 additions & 2 deletions dev-doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -55,7 +55,7 @@ Valid actions are:
:nothing, :create, :remove, :modify, :manage, :lock, :unlock

For more information, please consult the documentation for this resource:
<https://docs.chef.io/resource_reference.html>
<https://docs.chef.io/resources>

```shell
bundle exec chef-run ssh://my_user@host1:2222 directory /tmp/foo --identity-file ~/.ssh/id_rsa user test1 action=remove
Expand Down
2 changes: 1 addition & 1 deletion lib/chef_apply/action/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/chef_apply/action/converge_target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion lib/chef_apply/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/chef_apply/cli/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/chef_apply/startup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions lib/chef_apply/target_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/chef_apply/target_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/chef_apply/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/startup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/target_resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit edba5f7

Please sign in to comment.