diff --git a/CHEATSHEET.md b/CHEATSHEET.md index f6bff581..a9303da7 100644 --- a/CHEATSHEET.md +++ b/CHEATSHEET.md @@ -1,6 +1,6 @@ # CFEngine CLI cheatsheet -Quick reference for `cfengine COMMANDS` +Quick reference for `cfengine COMMANDS`. For the full command list, run `cfengine help` or `cfengine COMMAND --help`. ## Managing hosts @@ -86,7 +86,7 @@ cfengine init --policy-set # Initialize an example build project for working on a custom promise type (python) cfengine init --promise-type -# Initialize an exapmlte module project for build.cfengine.com (or internal use) +# Initialize an example module project for build.cfengine.com (or internal use) cfengine init --policy-module # Initialize an example policy module that takes input data diff --git a/CLAUDE.md b/CLAUDE.md index c674094e..a19d3437 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -48,4 +48,4 @@ We have different suites: - Unit tests in `tests/unit` test individual python functions. - Formatting tests in `tests/format` test the formatter (`cfengine format`). - Linting tests in `tests/lint` test the linter. -- Shell tests in `tests/shell` tests various subcommands and the tool as a whole in an end-to-end fashion. +- Shell tests in `tests/shell` test various subcommands and the tool as a whole in an end-to-end fashion. diff --git a/HACKING.md b/HACKING.md index 3f29c5aa..cdeefda3 100644 --- a/HACKING.md +++ b/HACKING.md @@ -16,7 +16,7 @@ If your editor does not do this automatically, you can run these tools from the make format ``` -## Installing from source: +## Installing from source For developers working on CFEngine CLI, you can install it globally using pipx: @@ -53,7 +53,7 @@ uv run bash tests/run-shell-tests.sh ## Releasing new versions -Releases are [automated using a GH Action](https://github.com/cfengine/cfengine-cli/blob/main/.github/workflows/pypi-publish.yml) +Releases are [automated using a GH Action](https://github.com/cfengine/cfengine-cli/blob/main/.github/workflows/pypi-publish.yml). We create tags and releases through the GitHub UI. Go to the releases section in GitHub: @@ -107,7 +107,7 @@ Go through the prompts: https://github.com/cfengine/cfengine-cli/releases/tag/0.2.0 ``` -Then check that everything went well; +Then check that everything went well: https://github.com/cfengine/cfengine-cli/actions diff --git a/src/cfengine_cli/cfengine_wrapper/arg_parse.py b/src/cfengine_cli/cfengine_wrapper/arg_parse.py index bc6c517c..1db499e9 100644 --- a/src/cfengine_cli/cfengine_wrapper/arg_parse.py +++ b/src/cfengine_cli/cfengine_wrapper/arg_parse.py @@ -50,7 +50,7 @@ def parse_wrapper_args(subp: argparse._SubParsersAction): remove_parser.add_argument( "module", nargs="+", - help="Module(s) for which to remove", + help="Module(s) to remove", ) add_parser = subp.add_parser( @@ -61,7 +61,7 @@ def parse_wrapper_args(subp: argparse._SubParsersAction): add_parser.add_argument( "module", nargs="+", - help="Module(s) for which to add", + help="Module(s) to add", ) _add_index_arg(add_parser) search_parser = subp.add_parser( @@ -72,7 +72,7 @@ def parse_wrapper_args(subp: argparse._SubParsersAction): search_parser.add_argument( "module", nargs="+", - help="Module(s) for which to lookup", + help="Module(s) to look up", ) _add_index_arg(search_parser) diff --git a/src/cfengine_cli/cfengine_wrapper/cfengine_commands.py b/src/cfengine_cli/cfengine_wrapper/cfengine_commands.py index 6389db48..c52d09c8 100644 --- a/src/cfengine_cli/cfengine_wrapper/cfengine_commands.py +++ b/src/cfengine_cli/cfengine_wrapper/cfengine_commands.py @@ -198,7 +198,7 @@ def report( for agent in clients: rc = _refresh_agent(agent) if rc != 0: - log.error(f"Refresh failed on {agent.label})") + log.error(f"Refresh failed on {agent.label}") errors += 1 for hub in hubs: @@ -207,7 +207,7 @@ def report( client_ips = [client.location.split("@", 1)[1] for client in clients] rc = _query_hub_delta(hub.hub, client_ips) if rc != 0: - log.error(f"Hub refresh failed on {hub.label})") + log.error(f"Hub refresh failed on {hub.label}") errors += 1 if errors > 0: diff --git a/src/cfengine_cli/cfengine_wrapper/cfengine_objects.py b/src/cfengine_cli/cfengine_wrapper/cfengine_objects.py index d8c917fd..40f22039 100644 --- a/src/cfengine_cli/cfengine_wrapper/cfengine_objects.py +++ b/src/cfengine_cli/cfengine_wrapper/cfengine_objects.py @@ -77,7 +77,7 @@ def _run_one(self, command: str) -> int: output = run_command(self.location, full_command, sudo=True) if ( output is None - ): # TODO: Test this, I've had some policy failing but returning output instead or error-code (I think) + ): # TODO: Test this, I've had some policy failing but returning output instead of error-code (I think) # Error already logged in run_command return 1 if output: diff --git a/src/cfengine_cli/changelog.py b/src/cfengine_cli/changelog.py index aa7a0679..c8c37092 100644 --- a/src/cfengine_cli/changelog.py +++ b/src/cfengine_cli/changelog.py @@ -2,7 +2,7 @@ Auto-detects which repos to include based on the current working directory (core, masterfiles, enterprise). -Enterprise' changelog also reflects changes in mission-portal, nova and buildscripts (dependency-updates). +Enterprise's changelog also reflects changes in mission-portal, nova and buildscripts (dependency-updates). Core and Masterfiles only reflect themselves. Usage: @@ -13,7 +13,7 @@ on 3.27.x this will check changelog for latest known (e.g. 3.27.1) and update the changelog for 3.27.1 -> 3.27.2 - cfengine dev generate-changelog -o 3.26.0..3.27.0 - on any branch will print changelog from version 2.26.0 -> 3.27.0 to stdout + on any branch will print changelog from version 3.26.0 -> 3.27.0 to stdout """ import os diff --git a/src/cfengine_cli/deptool-README.md b/src/cfengine_cli/deptool-README.md index 0f98cc7a..c59adcb2 100644 --- a/src/cfengine_cli/deptool-README.md +++ b/src/cfengine_cli/deptool-README.md @@ -7,7 +7,7 @@ It supports printing to stdout in the Markdown table format, and printing to fil It can also generate basic SBOMs in the CycloneDX JSON format (see [below](https://github.com/cfengine/buildscripts/tree/master/scripts#generating-cyclonedx-json-sboms) for usage instructions). It can be used as a replacement for the [cf-bottom](https://github.com/cfengine/cf-bottom/) `depstable` command. -`deptool.py` works on a local buildscripts repository. By default, the repository is assumed to be current working directory (i.e. `.`). +`deptool.py` works on a local buildscripts repository. By default, the repository is assumed to be the current working directory (i.e. `.`). A custom path for the local repository can be specified using the `--root` argument. Running the script will modify the git state of the repository by checking out branches (and with `--patch`, also overwriting and git-adding `README.md`), so it might be preferable to [use a copy of the buildscripts repository](https://github.com/cfengine/buildscripts/tree/master/scripts#using-a-copy-of-the-repository). @@ -56,7 +56,7 @@ WARNING:root:didn't find dep in line [| libgcc | [libexpat](https://libexpat.github.io/) | - | 2.6.3 | 2.6.3 | | [PHP](https://php.net/) | 8.3.13 | 8.3.13 | 8.3.15 | | [PostgreSQL](https://www.postgresql.org/) | 15.8 | 16.4 | 17.2 | -| [nghttp2](https://nghttp2.opg/) | - | - | 1.64.0 | +| [nghttp2](https://nghttp2.org/) | - | - | 1.64.0 | | [rsync](https://download.samba.org/pub/rsync/) | 3.3.0 | 3.3.0 | 3.3.0 | ``` diff --git a/src/cfengine_cli/deptool.py b/src/cfengine_cli/deptool.py index 74648933..4dfb977b 100644 --- a/src/cfengine_cli/deptool.py +++ b/src/cfengine_cli/deptool.py @@ -89,7 +89,7 @@ def is_whitespace(s: str): class GitRepo: - """Class responsible for working with locally checked-out repository""" + """Class responsible for working with a locally checked-out repository""" def __init__( self, @@ -281,7 +281,7 @@ def deps_list(self, ref="master"): else: filtered_lines = (x for x in options_lines if "var_append DEPS" in x) only_deps = (re.sub('.*DEPS "(.*)".*', "\\1", x) for x in filtered_lines) - # currently only_deps is generator of space-separated deps, + # currently only_deps is a generator of space-separated deps, # i.e. each item can contain several items, like this: # list(only_deps) = ["lcov", "pthreads-w32 libgnurx"] # to "flatten" it we first join using spaces and then split on spaces @@ -413,7 +413,7 @@ def updated_deps_markdown_table(self, refs): # of first column (with words "CFEngine version" in it) and, # possibly, last ("Notes", which is now second-to-last). # Between them are ref column widths, calculated earlier. - # Also we substract 2 to remove column "padding". + # Also we subtract 2 to remove column "padding". column_widths = ( [column_widths[1] - 2] + [ref_column_widths[ref] for ref in refs] # "CFEngine version" @@ -574,7 +574,7 @@ def comparison_md_table(self, refs, skip_unchanged=False): c_dep_data = collections.OrderedDict() bolded_in_row = 0 - # iterate over refs in non-overlapping pairs, and skipping the last odd ref + # iterate over refs in non-overlapping pairs, skipping the last odd ref for ref_A, ref_B in list(zip(refs, refs[1:]))[::2]: version_A = deps_data[dep][ref_A] version_B = deps_data[dep][ref_B] diff --git a/src/cfengine_cli/format.py b/src/cfengine_cli/format.py index 48d40aa8..f6082d66 100644 --- a/src/cfengine_cli/format.py +++ b/src/cfengine_cli/format.py @@ -598,7 +598,7 @@ def _can_single_line_promise(node: Node, indent: int, line_length: int) -> bool: return True if len(attrs) > 1: # We always want to multiline a promise with multiple attributes - # even if it would fit on one line, i.e this should be split: + # even if it would fit on one line, i.e. this should be split: # "foo" string => "bar", comment => "baz"; return False if next_sib and next_sib.type == "half_promise": @@ -615,7 +615,7 @@ def _can_single_line_promise(node: Node, indent: int, line_length: int) -> bool: children, indent, line_length ): # A promise with a stakeholder and no attributes might be split - # if the stakeholders are too long or include comments. i.e split this: + # if the stakeholders are too long or include comments, i.e. split this: # "foo" -> { "bar", "too long", "stakeholders", "list", "in here", "now" }; assert not attrs # Should have already returned in if above return False diff --git a/src/cfengine_cli/initialize_project.py b/src/cfengine_cli/initialize_project.py index ec331b8b..5627747a 100644 --- a/src/cfengine_cli/initialize_project.py +++ b/src/cfengine_cli/initialize_project.py @@ -18,7 +18,7 @@ def init_promise_type(name=None, non_interactive=False): name = name or _prompt_for_name( non_interactive, validate=False, - hint="""Try to follow typical naming conventions e.g. + hint="""Try to follow typical naming conventions, e.g. - promise-type-groups - promise-type-docker-compose """, diff --git a/src/cfengine_cli/lint.py b/src/cfengine_cli/lint.py index d49509f4..859c747e 100644 --- a/src/cfengine_cli/lint.py +++ b/src/cfengine_cli/lint.py @@ -66,12 +66,12 @@ KNOWN_FAULTY_FUNCTION_DEFS = {"regex_replace", "peers"} # Generally, we don't want to allow creating bodies / bundles with the same -# name as a built in function, as it can make things more confusing +# name as a built-in function, as it can make things more confusing # (harder to read / understand policy and look up definitions). # # There are a couple of pre-existing cases that we need to preserve for backwards # compatibility - bodies / bundles defined in masterfiles which have the same -# name as a built in function. +# name as a built-in function. @dataclass @@ -210,7 +210,7 @@ def __deepcopy__(self, _): class State: """This class is used to keep track of needed state while linting. - Not used in parsing, that is handled entirely by tree sitter library. + Not used in parsing, that is handled entirely by the tree sitter library. Used when we are iterating over (walking) nodes in the syntax tree. It has 3 different sets of information: @@ -607,7 +607,7 @@ def _discover(policy_file: PolicyFile, state: State) -> int: def _lint_promise_guard( node: Node, state: State, location: str, syntax_data: SyntaxData ): - """Check that a promise type guard (e.g. `vars:`) for deprecation or unknown type.""" + """Check a promise type guard (e.g. `vars:`) for deprecation or unknown type.""" assert _text(node) and len(_text(node)) > 1 and _text(node)[-1] == ":" promise_type = _text(node)[0:-1] if state.strict and promise_type in syntax_data.DEPRECATED_PROMISE_TYPES: @@ -701,7 +701,7 @@ def _lint_promise(node: Node, state: State, location: str, _syntax_data: SyntaxD ) if len(value_nodes) > 1: - # Too many of vars_types was found + # Too many of vars_types were found # TODO: We could improve _highlight_range to highlight multiple nodes in a nice way nodes = ", ".join([_text(x) for x in value_nodes]) raise ValidationError( diff --git a/src/cfengine_cli/main.py b/src/cfengine_cli/main.py index e18195f1..d9b39c9b 100644 --- a/src/cfengine_cli/main.py +++ b/src/cfengine_cli/main.py @@ -112,7 +112,7 @@ def _get_arg_parser(): tst.add_argument( "files", nargs="*", - help="Files/Folder to lint (default is . (the entire project) )", + help="Files/Folder to lint (default is . (the entire project))", ) dev_parser = subp.add_parser( @@ -168,14 +168,14 @@ def _get_arg_parser(): Auto-detects which repos to include based on the current working directory (core, masterfiles, enterprise) -Enterprise' changelog also reflects changes in mission-portal, nova and buildscripts (dependency-updates) +Enterprise's changelog also reflects changes in mission-portal, nova and buildscripts (dependency-updates) Core and Masterfiles only reflect themselves""", epilog="""Examples: - cfengine dev generate-changelog on 3.27.x this will check changelog for latest known (e.g. 3.27.1) and update the changelog for 3.27.1 -> 3.27.2 - cfengine dev generate-changelog -o 3.26.0..3.27.0 - on any branch will print changelog from version 2.26.0 -> 3.27.0 to stdout""", + on any branch will print changelog from version 3.26.0 -> 3.27.0 to stdout""", formatter_class=argparse.RawDescriptionHelpFormatter, ) parser.add_argument( diff --git a/src/cfengine_cli/masterfiles/download.py b/src/cfengine_cli/masterfiles/download.py index f651d2a3..45ca1774 100644 --- a/src/cfengine_cli/masterfiles/download.py +++ b/src/cfengine_cli/masterfiles/download.py @@ -20,9 +20,9 @@ """Rationale for each version: * 3.10.0:\\ For some reason, the `"Masterfiles ready-to-install tarball"` is a .tar.gz tarball, rather than a .pkg.tar.gz tarball. - However, an unlisted analoguous URL for the .pkg.tar.gz tarball does exist. + However, an unlisted analogous URL for the .pkg.tar.gz tarball does exist. * 3.9.2:\\ - No masterfiles are listed in the release data, but an unlisted analoguous URL does exist.""" + No masterfiles are listed in the release data, but an unlisted analogous URL does exist.""" HARDCODED_VERSIONS = COMMUNITY_ONLY_VERSIONS + MISSING_DATA_VERSIONS diff --git a/tests/format/002_basics.expected.cf b/tests/format/002_basics.expected.cf index 04bb88a4..0c0ad31e 100644 --- a/tests/format/002_basics.expected.cf +++ b/tests/format/002_basics.expected.cf @@ -1,5 +1,5 @@ # This shows some basics of policy language, without getting -# too deep into edge cases and wrappting etc. +# too deep into edge cases and wrapping etc. body common control { inputs => { "/var/cfengine/inputs/some_file.cf" }; @@ -34,7 +34,7 @@ bundle agent main baz:: "bam" if => "bar", - # Comment at atttribute level + # Comment at attribute level string => "some_value"; "empty_list" slist => {}; diff --git a/tests/format/002_basics.input.cf b/tests/format/002_basics.input.cf index 1c54a7c9..2022cf93 100644 --- a/tests/format/002_basics.input.cf +++ b/tests/format/002_basics.input.cf @@ -1,5 +1,5 @@ # This shows some basics of policy language, without getting -# too deep into edge cases and wrappting etc. +# too deep into edge cases and wrapping etc. body common control{ inputs => { "/var/cfengine/inputs/some_file.cf" }; @@ -27,7 +27,7 @@ string => "some_value"; baz:: "bam" if => "bar", -# Comment at atttribute level +# Comment at attribute level string => "some_value"; "empty_list" slist => { diff --git a/tests/format/011_promises.expected.cf b/tests/format/011_promises.expected.cf index 46ec5088..2939916d 100644 --- a/tests/format/011_promises.expected.cf +++ b/tests/format/011_promises.expected.cf @@ -361,7 +361,7 @@ bundle common cfe_internal_inputs enterprise_edition:: "input[enterprise_knowledge]" string => "cfe_internal/enterprise/CFE_knowledge.cf", - comment => "Settings mostly releated to CFEngine Enteprise Mission Portal"; + comment => "Settings mostly related to CFEngine Enterprise Mission Portal"; "input[enterprise_main]" string => "cfe_internal/enterprise/main.cf", diff --git a/tests/format/011_promises.input.cf b/tests/format/011_promises.input.cf index 40d19be9..5becd946 100644 --- a/tests/format/011_promises.input.cf +++ b/tests/format/011_promises.input.cf @@ -247,7 +247,7 @@ bundle common cfe_internal_inputs "input[enterprise_knowledge]" string => "cfe_internal/enterprise/CFE_knowledge.cf", - comment => "Settings mostly releated to CFEngine Enteprise Mission Portal"; + comment => "Settings mostly related to CFEngine Enterprise Mission Portal"; "input[enterprise_main]" string => "cfe_internal/enterprise/main.cf", diff --git a/tests/run-format-tests.sh b/tests/run-format-tests.sh index 150af46c..9fc50040 100644 --- a/tests/run-format-tests.sh +++ b/tests/run-format-tests.sh @@ -1,4 +1,4 @@ -#/usr/bin/env bash +#!/usr/bin/env bash set -e # set -x diff --git a/tests/run-lint-tests.sh b/tests/run-lint-tests.sh index 624f6fff..3f32127d 100644 --- a/tests/run-lint-tests.sh +++ b/tests/run-lint-tests.sh @@ -1,4 +1,4 @@ -#/usr/bin/env bash +#!/usr/bin/env bash set -e # set -x diff --git a/tests/run-shell-tests.sh b/tests/run-shell-tests.sh index a157117c..b40c2eee 100644 --- a/tests/run-shell-tests.sh +++ b/tests/run-shell-tests.sh @@ -1,4 +1,4 @@ -#/usr/bin/env bash +#!/usr/bin/env bash set -e # set -x diff --git a/tests/shell/003-format.sh b/tests/shell/003-format.sh index 90c1e791..089bdef9 100755 --- a/tests/shell/003-format.sh +++ b/tests/shell/003-format.sh @@ -6,7 +6,7 @@ set -x # Verify that the line length parameter shows up in help cfengine format -h | grep -- "--line-length" -# Test three common line length +# Test three common line lengths for ll in 80 100 120; do # Format the following HEREDOC and let wc count the longest line l=$(cfengine format --line-length $ll - <<-EOF |