Skip to content

Commit

Permalink
make var naming consistent, update prompt text
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-orlando committed Nov 10, 2023
1 parent d87e468 commit c0a4c81
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
14 changes: 7 additions & 7 deletions secureli/actions/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ def _install_secureli(self, folder_path: Path, always_yes: bool) -> VerifyResult
languages = list(analyze_result.language_proportions.keys())
self.action_deps.echo.print(f"Overall Detected Languages: {languages}")

linter_languages = self._prompt_get_lint_config_languages(
lint_languages = self._prompt_get_lint_config_languages(
languages, always_yes
)

language_config_result = (
self.action_deps.language_support._build_pre_commit_config(
languages, linter_languages
languages, lint_languages
)
)

Expand All @@ -172,7 +172,7 @@ def _install_secureli(self, folder_path: Path, always_yes: bool) -> VerifyResult

config = SecureliConfig(
languages=languages,
lint_languages=linter_languages,
lint_languages=lint_languages,
version_installed=metadata.version,
)
self.action_deps.secureli_config.save(config)
Expand Down Expand Up @@ -218,17 +218,17 @@ def _prompt_get_lint_config_languages(
if always_yes:
return set(languages)

linter_languages: set[str] = set()
lint_languages: set[str] = set()

for language in languages:
add_linter = self.action_deps.echo.confirm(
f"Add lint pre-commit(s) for {language}?", default_response=True
f"Add lint pre-commit hook(s) for {language}?", default_response=True
)

if add_linter:
linter_languages.add(language)
lint_languages.add(language)

return linter_languages
return lint_languages

def _update_secureli(self, always_yes: bool):
"""
Expand Down
10 changes: 5 additions & 5 deletions secureli/services/language_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def secret_detection_hook_id(self, languages: list[str]) -> Optional[str]:
:param languages: list of languages to check support for
:return: The hook ID to use for secrets analysis if supported, otherwise None.
"""
# linter_languages param can be an empty set since we only need secrets detection hooks
# lint_languages param can be an empty set since we only need secrets detection hooks
language_config = self._build_pre_commit_config(languages, set())
config = language_config.config_data
secrets_detecting_repos_data = self.data_loader(
Expand Down Expand Up @@ -193,23 +193,23 @@ def create_repo(raw_repo: dict) -> Repo:
return HookConfiguration(repos=repos)

def _build_pre_commit_config(
self, languages: list[str], linter_languages: set[str]
self, languages: list[str], lint_languages: set[str]
) -> BuildConfigResult:
"""
Builds the final .pre-commit-config.yaml from all supported repo languages. Also returns any and all
linter configuration data.
:param languages: list of languages to get calculated configuration for.
:param linter_languages: set of languages to add lint pre-commit hooks for.
:param lint_languages: set of languages to add lint pre-commit hooks for.
:return: BuildConfigResult
"""
config_data = []
successful_languages: list[str] = []
linter_configs: list[LinterConfig] = []
config_languages = [*languages, "base"]
config_linter_languages = set([*linter_languages, "base"])
config_lint_languages = set([*lint_languages, "base"])

for language in config_languages:
include_linter = language in config_linter_languages
include_linter = language in config_lint_languages
result = self.language_config.get_language_config(language, include_linter)
if result.config_data:
successful_languages.append(language)
Expand Down
16 changes: 8 additions & 8 deletions tests/services/test_language_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ def mock_loader_side_effect(resource):
mock_data_loader.side_effect = mock_loader_side_effect

languages = ["RadLang"]
linter_languages = set(languages)
lint_languages = set(languages)

build_config_result = language_support_service._build_pre_commit_config(
languages, linter_languages
languages, lint_languages
)

metadata = language_support_service.apply_support(["RadLang"], build_config_result)
Expand Down Expand Up @@ -278,10 +278,10 @@ def test_that_language_support_throws_exception_when_language_config_file_cannot
)

languages = ["RadLang"]
linter_languages = set(languages)
lint_languages = set(languages)

build_config_result = language_support_service._build_pre_commit_config(
languages, linter_languages
languages, lint_languages
)

mock_open.side_effect = IOError
Expand All @@ -307,10 +307,10 @@ def test_that_language_support_handles_invalid_language_config(
)

languages = ["RadLang"]
linter_languages = set(languages)
lint_languages = set(languages)

build_config_result = language_support_service._build_pre_commit_config(
languages, linter_languages
languages, lint_languages
)

metadata = language_support_service.apply_support(languages, build_config_result)
Expand All @@ -337,10 +337,10 @@ def test_that_language_support_handles_empty_repos_list(
mock_data_loader.return_value = ""

languages = ["RadLang"]
linter_languages = set(languages)
lint_languages = set(languages)

build_config_result = language_support_service._build_pre_commit_config(
languages, linter_languages
languages, lint_languages
)

assert build_config_result.config_data["repos"] == []

0 comments on commit c0a4c81

Please sign in to comment.