Skip to content

[Bash]: lint errors found #6562

@kenjones-cisco

Description

@kenjones-cisco
Description

After generating a bash client, and running the code through shellcheck shellcheck-src there are many linting errors found.

script_name=`basename "$0"`
            ^-- SC2006: Use $(..) instead of legacy `..`.

apikey_auth_credential=""
^-- SC2034: apikey_auth_credential appears unused. Verify it or export it.

       -e 's/?/%3F/g' <<<$raw_url);
                         ^-- SC2086: Double quote to prevent globbing and word splitting.

    echo $value
         ^-- SC2086: Double quote to prevent globbing and word splitting.

        echo $1
             ^-- SC2086: Double quote to prevent globbing and word splitting.

            api_key_header_in_cli="YES"
            ^-- SC2034: api_key_header_in_cli appears unused. Verify it or export it.

    local body_parameter_count=${#body_parameters[@]}
          ^-- SC2034: body_parameter_count appears unused. Verify it or export it.

            local parameter_values=($(sed -e 's/'":::"'/\n/g' <<<"${operation_parameters[$qparam]}"))
                                    ^-- SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

        if [[ $path_template =~ (.*)(\\{$pparam\\})(.*) ]]; then
                                ^-- SC1009: The mentioned parser error was in this regex.
                                    ^-- SC1073: Couldn't parse this regex grouping.
                                      ^-- SC1072: Unexpected . Fix any mentioned problems and try again.

    local query_parameter_count=${#query_params[@]}
          ^-- SC2034: query_parameter_count appears unused. Verify it or export it.

        local parameter_values=($(sed -e 's/'":::"'/\n/g' <<<"${operation_parameters[$qparam]}"))
                                ^-- SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

        if [[ -n "${parameter_values[@]}" ]]; then
                 ^-- SC2199: Arrays implicitly concatenate in [[ ]]. Use a loop (or explicit * instead of @).

                    parameter_value+="\t"
                                      ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

    echo $path_template
         ^-- SC2086: Double quote to prevent globbing and word splitting.

read -d '' ops <<EOF
^-- SC2162: read without -r will mangle backslashes.

    echo -e "  -h,--help\t\t\t\tPrint this help"
                        ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                          ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                            ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                              ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

    echo -e "  -V,--version\t\t\t\tPrint API version"
                           ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                             ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                               ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                                 ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

    echo -e "  --about\t\t\t\tPrint the information about service"
                      ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                        ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                          ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                            ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

    echo -e "  --host ${CYAN}<url>${OFF}\t\t\t\tSpecify the host URL "
                                        ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                                          ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                                            ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                                              ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

echo -e "              \t\t\t\t(e.g. 'https://127.0.0.1:8080')"
                       ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                         ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                           ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                             ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

    echo -e "  --force\t\t\t\tForce command invocation in spite of missing"
                      ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                        ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                          ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                            ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

    echo -e "         \t\t\t\trequired parameters or wrong content type"
                      ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                        ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                          ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                            ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

    echo -e "  --dry-run\t\t\t\tPrint out the cURL command without"
                        ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                          ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                            ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                              ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

    echo -e "           \t\t\t\texecuting it"
                        ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                          ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                            ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                              ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

    echo -e "  -nc,--no-colors\t\t\tEnforce print without colors, otherwise autodected"
                              ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                                ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                                  ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

    echo -e "  -ac,--accept ${YELLOW}<mime-type>${OFF}\t\tSet the 'Accept' header in the request"
                                                      ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".
                                                        ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

    echo -e "  -ct,--content-type ${YELLOW}<mime-type>${OFF}\tSet the 'Content-type' header in "
                                                            ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

    echo -e "                                \tthe request"
                                             ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

read -d '' appdescription <<EOF
^-- SC2162: read without -r will mangle backslashes.

    if [ $? -ne 0 ]; then
         ^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.

    local headers_curl=$(header_arguments_to_curl)
          ^-- SC2155: Declare and assign separately to avoid masking return values.

        echo -e "\t- application/vnd.cia.v1+json"
                 ^-- SC1117: Backslash is literal in "\t". Prefer explicit escaping: "\\t".

        IFS='==' read body_key sep body_value <<< "$key"
        ^-- SC2162: read without -r will mangle backslashes.

        IFS=':=' read body_key sep body_value <<< "$key"
        ^-- SC2162: read without -r will mangle backslashes.
                               ^-- SC2034: sep appears unused. Verify it or export it.

        IFS=':' read header_name header_value <<< "$key"
        ^-- SC2162: read without -r will mangle backslashes.

    cat - > $body_content_temp_file
            ^-- SC2086: Double quote to prevent globbing and word splitting.

        IFS='=' read parameter_name parameter_value <<< "$key"
        ^-- SC2162: read without -r will mangle backslashes.
Swagger-codegen version

latest from master

Command line used for generation

java -jar swagger-codegen-cli.jar generate -i api.yaml -o out/ --lang bash -c swagger_config.json

Suggest a fix/enhancement

PR coming

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions