Open casperdcl opened 2 years ago
❌ Merging this PR will decrease code quality in the affected files by 0.11%.
Quality metrics | Before | After | Change |
---|---|---|---|
Complexity | 41.79 ⛔ | 42.09 ⛔ | 0.30 👎 |
Method Length | 110.09 🙂 | 112.03 🙂 | 1.94 👎 |
Working memory | 18.29 ⛔ | 18.28 ⛔ | -0.01 👍 |
Quality | 29.55% 😞 | 29.44% 😞 | -0.11% 👎 |
Other metrics | Before | After | Change |
---|---|---|---|
Lines | 1055 | 1068 | 13 |
Changed files | Quality Before | Quality After | Quality Change |
---|---|---|---|
shtab/init.py | 29.55% 😞 | 29.44% 😞 | -0.11% 👎 |
Here are some functions in these files that still need a tune-up:
File | Function | Complexity | Length | Working Memory | Quality | Recommendation |
---|---|---|---|---|---|---|
shtab/init.py | get_bash_commands | 78 ⛔ | 506 ⛔ | 26 ⛔ | 2.72% ⛔ | Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions |
shtab/init.py | complete_zsh | 62 ⛔ | 754 ⛔ | 25 ⛔ | 3.53% ⛔ | Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions |
shtab/init.py | get_bash_commands.recurse | 58 ⛔ | 452 ⛔ | 26 ⛔ | 4.43% ⛔ | Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions |
shtab/init.py | complete_tcsh | 57 ⛔ | 403 ⛔ | 19 ⛔ | 8.18% ⛔ | Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions |
shtab/init.py | complete_zsh.recurse | 18 🙂 | 214 ⛔ | 16 ⛔ | 31.98% 😞 | Try splitting into smaller methods. Extract out complex expressions |
The emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.
Please see our documentation here for details on how these metrics are calculated.
We are actively working on this report - lots more documentation and extra metrics to come!
Help us improve this quality report!
@casperdcl Hi, I try this commit but it doesn't work on my side. Steps:
pip install git+https://github.com/iterative/shtab.git@default_complete
DEFAULT_FUNCTIONS
:
shtab.add_argument_to(self.parser, ["-s", "--print-completion"], default_complete=DEFAULT_FUNCTIONS)
run -s zsh
However, the script doesn't contains _default
either.
……
_shtab_run_tune_options=(
"(- :)"{-h,--help}"[show this help message and exit]"
{-c,--config}"[Path to a configuration file in json or yaml format.]:config:"
"--print_config[Print the configuration after applying all other arguments and exit.]:print_config:"
"--seed_everything[Set to an int to run seed_everything with this value before classes instantiation]:seed_everything:"
"--trainer[Path to a configuration file.]:trainer:"
……
Here is the minimal reproduction:
pip install git+https://github.com/iterative/shtab.git@default_complete
create test.py
#!/usr/bin/env python
import argparse
import shtab # for completion magic
def get_main_parser(): parser = argparse.ArgumentParser(prog="pathcomplete") shtab.add_argument_to(parser, ["-s", "--print-completion"], default_complete="_default") # magic!
parser.add_argument("file", nargs="?")
parser.add_argument("--dir", default=".")
return parser
if name == "main":
parser = get_main_parser()
args = parser.parse_args()
print("received
3. print completion
```console
λ python test.py -s zsh
#compdef pathcomplete
# AUTOMATCALLY GENERATED by `shtab`
_shtab_pathcomplete_commands() {
local _commands=(
)
_describe 'pathcomplete commands' _commands
}
_shtab_pathcomplete_options=(
"(- :)"{-h,--help}"[show this help message and exit]"
{-s,--print-completion}"[print shell completion script]:print_completion:(bash zsh tcsh)"
"--dir[]:dir:"
)
_shtab_pathcomplete() {
local context state line curcontext="$curcontext"
_arguments -C $_shtab_pathcomplete_options \
': :_shtab_pathcomplete_commands' \
'*::: :->pathcomplete'
case $state in
pathcomplete)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:_shtab_pathcomplete-$line[1]:"
case $line[1] in
esac
esac
}
typeset -A opt_args
_shtab_pathcomplete "$@"
Fixes #65 /CC @tshu-w