[
  {
    "path": ".coveragerc",
    "content": "[run]\nbranch = True\nsource = bashate\nomit = bashate/tests/*\n\n[report]\nignore_errors = True\n"
  },
  {
    "path": ".gitignore",
    "content": "*.py[cod]\n\n# C extensions\n*.so\n\n# Packages\n*.egg\n*.egg-info\ndist\nbuild\neggs\nparts\nbin\nvar\nsdist\ndevelop-eggs\n.installed.cfg\nlib\nlib64\n\n# Installer logs\npip-log.txt\n\n# Unit test / coverage reports\n.coverage\n.tox\nnosetests.xml\n.stestr/\ncover/\n\n# Translations\n*.mo\n\n# Mr Developer\n.mr.developer.cfg\n.project\n.pydevproject\n\n# Complexity\noutput/*.html\noutput/*/index.html\n\n# Sphinx\ndoc/build\n\n# pbr generates these\nAUTHORS\nChangeLog\n\n# Editors\n*~\n.*.swp"
  },
  {
    "path": ".gitreview",
    "content": "[gerrit]\nhost=review.opendev.org\nport=29418\nproject=openstack/bashate.git\n"
  },
  {
    "path": ".mailmap",
    "content": "# Format is:\n# <preferred e-mail> <other e-mail 1>\n# <preferred e-mail> <other e-mail 2>"
  },
  {
    "path": ".pre-commit-hooks.yaml",
    "content": "---\n\n# For use with pre-commit.\n# See usage instructions at https://pre-commit.com\n\n-   id: bashate\n    name: bashate\n    description: This hook runs bashate for linting shell scripts\n    entry: bashate\n    language: python\n    types: [shell]\n"
  },
  {
    "path": ".stestr.conf",
    "content": "[DEFAULT]\ntest_path=./bashate/tests"
  },
  {
    "path": ".zuul.d/jobs.yaml",
    "content": "- project:\n    templates:\n      - openstack-python3-jobs\n      - publish-openstack-docs-pti\n      - release-notes-jobs-python3\n    check:\n      jobs:\n        - openstack-tox-pep8\n        - openstack-tox-py39\n        - openstack-tox-py310\n        - openstack-tox-py311\n        - openstack-tox-py312\n        - bashate-devstack\n    gate:\n      jobs:\n        - openstack-tox-pep8\n        - openstack-tox-py39\n        - openstack-tox-py310\n        - openstack-tox-py311\n        - openstack-tox-py312\n        - bashate-devstack\n\n- job:\n    name: bashate-devstack\n    run: playbooks/bashate-devstack-master/run.yaml\n    required-projects:\n      - openstack/devstack\n"
  },
  {
    "path": "CONTRIBUTING.rst",
    "content": "The source repository for this project can be found at:\n\n   https://opendev.org/openstack/bashate\n\nPull requests submitted through GitHub are not monitored.\n\nTo start contributing to OpenStack, follow the steps in the contribution guide\nto set up and use Gerrit:\n\n   https://docs.openstack.org/contributors/code-and-documentation/quick-start.html\n\nBugs should be filed on Launchpad:\n\n   https://bugs.launchpad.net/bash8\n\nFor more specific information about contributing to this repository, see the\nBashate contributor guide:\n\n   https://docs.openstack.org/bashate/latest/contributor/contributing.html\n"
  },
  {
    "path": "HACKING.rst",
    "content": "bashate Style Commandments\n===============================================\n\nRead the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/\n"
  },
  {
    "path": "LICENSE",
    "content": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n"
  },
  {
    "path": "README.rst",
    "content": "===============================\nbashate\n===============================\n\nA pep8 equivalent for bash scripts\n\nThis program attempts to be an automated style checker for bash scripts\nto fill the same part of code review that pep8 does in most OpenStack\nprojects. It started from humble beginnings in the DevStack project,\nand will continue to evolve over time.\n\nThe output format aims to follow `pycodestyle (pep8) default output format\n<https://github.com/PyCQA/pycodestyle/blob/master/pycodestyle.py#L108>`_.\n\n\n- Free software: Apache license\n- Documentation: https://docs.openstack.org/bashate\n- Source: https://opendev.org/openstack/bashate/\n- Bugs: https://bugs.launchpad.net/bash8\n- Release notes: https://docs.openstack.org/releasenotes/bashate/index.html\n- Contributing: https://docs.openstack.org/bashate/latest/contributor/index.html\n\nCurrently Supported Checks\n--------------------------\n\nErrors\n~~~~~~\n\nBasic white space errors, for consistent indenting\n\n- E001: check that lines do not end with trailing whitespace\n- E002: ensure that indents are only spaces, and not hard tabs\n- E003: ensure all indents are a multiple of 4 spaces\n- E004: file did not end with a newline\n- E005: file does not begin with #! or have a .sh prefix\n- E006: check for lines longer than 79 columns\n\nStructure Errors\n~~~~~~~~~~~~~~~~\n\nA set of rules that help keep things consistent in control blocks.\nThese are ignored on long lines that have a continuation, because\nunrolling that is kind of \"interesting\"\n\n- E010: *do* not on the same line as *for*\n- E011: *then* not on the same line as *if* or *elif*\n- E012: heredoc didn't end before EOF\n- E020: Function declaration not in format ``^function name {$``\n\nObsolete, deprecated or unsafe syntax\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nRules to identify obsolete, deprecated or unsafe syntax that should\nnot be used\n\n- E040: Syntax errors reported by `bash -n`\n- E041: Usage of $[ for arithmetic is deprecated for $((\n- E042: local declaration hides errors\n- E043: arithmetic compound has inconsistent return semantics\n- E044: Use [[ for =~,<,> comparisions\n"
  },
  {
    "path": "bashate/__init__.py",
    "content": "# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the License. You may obtain\n# a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n# License for the specific language governing permissions and limitations\n# under the License.\n\nimport pbr.version\n\n\n__version__ = pbr.version.VersionInfo(\n    'bashate').version_string_with_vcs()\n"
  },
  {
    "path": "bashate/__main__.py",
    "content": "from bashate import main\nimport sys\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n"
  },
  {
    "path": "bashate/bashate.py",
    "content": "#!/usr/bin/env python\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n# License for the specific language governing permissions and limitations\n# under the License.\n\nimport argparse\nimport fileinput\nimport os\nimport re\nimport shlex\nimport subprocess\nimport sys\n\nimport bashate\nfrom bashate import messages\n\nMESSAGES = messages.MESSAGES\n\n\ndef is_continuation(line):\n    return re.search(r'\\\\\\s*$', line)\n\n\ndef check_for_do(line, report):\n    if not is_continuation(line):\n        match = re.match(r'^\\s*(for|while|until)\\s', line)\n        if match:\n            operator = match.group(1).strip()\n            if operator == \"for\":\n                # \"for i in ...\" and \"for ((\" is bash, but\n                # \"for (\" is likely from an embedded awk script,\n                # so skip it\n                if re.search(r'for \\([^\\(]', line):\n                    return\n            if not re.search(r';\\s*do$', line):\n                report.print_error((MESSAGES['E010'].msg % operator), line)\n\n\ndef check_if_then(line, report):\n    if not is_continuation(line):\n        if re.search(r'^\\s*(el)?if \\[', line):\n            if not re.search(r';\\s*then$', line):\n                report.print_error(MESSAGES['E011'].msg, line)\n\n\ndef check_no_trailing_whitespace(line, report):\n    if re.search(r'[ \\t]+$', line):\n        report.print_error(MESSAGES['E001'].msg, line)\n\n\ndef check_no_long_lines(line, report, max_line_length):\n    if len(line.rstrip(\"\\r\\n\")) > max_line_length:\n        report.print_error(MESSAGES['E006'].msg, line)\n\n\ndef check_indents(logical_line, report):\n    # this is rather complex to handle argument offset indenting;\n    # primarily done by emacs.  If there is an argument, it will try\n    # to line up the following arguments underneath it, e.g.\n    #   foobar_cmd bar baz \\\n    #              moo boo\n    # Thus the offset in this case might not be a strict multiple of 4\n\n    # Find the offset of the first argument of the command (if it has\n    # one)\n    m = re.search(r'^(?P<indent>[ \\t]+)?(?P<cmd>\\S+)(?P<ws>\\s+)(?P<arg>\\S+)',\n                  logical_line[0])\n    arg_offset = None\n    if m:\n        arg_offset = len(m.group('indent')) if m.group('indent') else 0\n        arg_offset += len(m.group('cmd')) + len(m.group('ws'))\n\n    # go through each line\n    for lineno, line in enumerate(logical_line):\n        m = re.search(r'^(?P<indent>[ \\t]+)', line)\n        if m:\n            # no tabs, only spaces\n            if re.search(r'\\t', m.group('indent')):\n                report.print_error(MESSAGES['E002'].msg, line)\n\n            offset = len(m.group('indent'))\n\n            # the first line and lines without an argument should be\n            # offset by 4 spaces\n            if (lineno == 0) or (arg_offset is None):\n                if (offset % 4) != 0:\n                    report.print_error(MESSAGES['E003'].msg, line)\n            else:\n                # other lines are allowed to line up with the first\n                # argument, or be multiple-of 4 spaces\n                if offset != arg_offset and (offset % 4) != 0:\n                    report.print_error(MESSAGES['E003'].msg, line)\n\n\ndef check_function_decl(line, report):\n    failed = False\n    if line.startswith(\"function\"):\n        if not re.search(r'^function [\\w-]* \\{$', line):\n            failed = True\n    else:\n        # catch the case without \"function\", e.g.\n        # things like '^foo() {'\n        if re.search(r'^\\s*?\\(\\)\\s*?\\{', line):\n            failed = True\n\n    if failed:\n        report.print_error(MESSAGES['E020'].msg, line)\n\n\ndef starts_heredoc(line):\n    # note, watch out for <<EOF and <<'EOF' ; quotes in the\n    # deliminator are part of syntax\n    m = re.search(r\"[^<]<<\\s*([\\'\\\"]?)(?P<token>\\w+)([\\'\\\"]?)\", line)\n    return m.group('token') if m else False\n\n\ndef end_of_heredoc(line, token):\n    return token and re.search(r\"^%s\\s*$\" % token, line)\n\n\ndef check_arithmetic(line, report):\n    if \"$[\" in line:\n        report.print_error(MESSAGES['E041'].msg, line)\n\n\ndef check_bare_arithmetic(line, report):\n    if line.lstrip().startswith(\"((\"):\n        report.print_error(MESSAGES['E043'].msg, line)\n\n\ndef check_local_subshell(line, report):\n    # XXX: should we increase the string checking to see if the $( is\n    # anywhere with a string being set?  Risk of false positives?x\n    if line.lstrip().startswith('local ') and \\\n       any(s in line for s in ('=$(', '=`', '=\"$(', '=\"`')):\n        report.print_error(MESSAGES['E042'].msg, line)\n\n\ndef check_hashbang(line, filename, report):\n    # this check only runs on the first line\n    #  maybe this should check for shell?\n    if (not filename.endswith(\".sh\") and not line.startswith(\"#!\") and\n       not os.path.basename(filename).startswith('.')):\n        report.print_error(MESSAGES['E005'].msg, line)\n\n\ndef check_conditional_expression(line, report):\n    # We're really starting to push the limits of what we can do without\n    # a complete bash syntax parser here.  For example\n    # > [[ $foo =~ \" [ \" ]] && [[ $bar =~ \" ] \" ]]\n    # would be valid but mess up a simple regex matcher for \"[.*]\".\n    # Let alone dealing with multiple-line-spanning etc...\n    #\n    # So we'll KISS and just look for simple, one line,\n    # > if [ $foo =~ \"bar\" ]; then\n    # type statements, which are the vast majority of typo errors.\n    #\n    # shlex is pretty helpful in getting us something we can walk to\n    # find this pattern.  It does however have issues with\n    # unterminated quotes on multi-line strings (e.g.)\n    #\n    # foo=\"bar   <-- we only see this bit in \"line\"\n    #  baz\"\n    #\n    # So we're just going to ignore parser failures here and move on.\n    # Possibly in the future we could pull such multi-line strings\n    # into \"logical_line\" below, and pass that here and have shlex\n    # break that up.\n    try:\n        toks = shlex.shlex(line)\n        toks.wordchars = \"[]=~\"\n        toks = list(toks)\n    except ValueError:\n        return\n\n    in_single_bracket = False\n    for tok in toks:\n        if tok == '[':\n            in_single_bracket = True\n        elif tok in ('=~', '<', '>') and in_single_bracket:\n            report.print_error(MESSAGES['E044'].msg, line)\n        elif tok == ']':\n            in_single_bracket = False\n\n\ndef check_syntax(filename, report):\n    # run the file through \"bash -n\" to catch basic syntax errors and\n    # other warnings\n    matches = []\n\n    # sample lines we want to match:\n    # foo.sh: line 4: warning: \\\n    #    here-document at line 1 delimited by end-of-file (wanted `EOF')\n    # foo.sh: line 9: syntax error: unexpected end of file\n    # foo.sh: line 7: syntax error near unexpected token `}'\n    #\n    # i.e. consistency with \":\"'s isn't constant, so just do our\n    # best...\n    r = re.compile(\n        '^(?P<file>.*): line (?P<lineno>[0-9]+): (?P<error>.*)')\n    # we are parsing the error message, so force it to ignore the\n    # system locale so we don't get messages in another language\n    bash_environment = os.environ\n    bash_environment['LC_ALL'] = 'C'\n    proc = subprocess.Popen(\n        ['bash', '-n', filename], stdout=subprocess.PIPE,\n        stderr=subprocess.PIPE, env=bash_environment,\n        universal_newlines=True)\n    outputs = proc.communicate()\n\n    for line in outputs[1].split('\\n'):\n        m = r.match(line)\n        if m:\n            matches.append(m)\n\n    for m in matches:\n        if 'syntax error' in m.group('error'):\n            msg = '%s: %s' % (MESSAGES['E040'].msg, m.group('error'))\n            report.print_error(msg, filename=filename,\n                               filelineno=int(m.group('lineno')))\n\n        # Matching output from bash warning about here-documents not\n        # ending.\n        # FIXME: are there other warnings that might come out\n        # with \"bash -n\"?  A quick scan of the source code suggests\n        # no, but there might be other interesting things we could\n        # catch.\n        if 'warning:' in m.group('error'):\n            if 'delimited by end-of-file' in m.group('error'):\n                start = re.match('^.*line (?P<start>[0-9]+).*$',\n                                 m.group('error'))\n                report.print_error(\n                    MESSAGES['E012'].msg % int(start.group('start')),\n                    filename=filename,\n                    filelineno=int(m.group('lineno')))\n\n\nclass BashateRun(object):\n\n    def __init__(self):\n        self.error_count = 0\n        self.error_list = None\n        self.ignore_list = None\n        self.warning_count = 0\n        self.warning_list = None\n\n    def register_ignores(self, ignores):\n        if ignores:\n            self.ignore_list = '^(' + '|'.join(ignores.split(',')) + ')'\n\n    def register_warnings(self, warnings):\n        if warnings:\n            self.warning_list = '^(' + '|'.join(warnings.split(',')) + ')'\n\n    def register_errors(self, errors):\n        if errors:\n            self.error_list = '^(' + '|'.join(errors.split(',')) + ')'\n\n    def should_ignore(self, error):\n        return self.ignore_list and re.search(self.ignore_list, error)\n\n    def should_warn(self, error):\n        # if in the errors list, overrides warning level\n        if self.error_list and re.search(self.error_list, error):\n            return False\n        if messages.is_default_warning(error):\n            return True\n        return self.warning_list and re.search(self.warning_list, error)\n\n    def print_error(self, error, line='',\n                    filename=None, filelineno=None):\n        if self.should_ignore(error):\n            return\n\n        warn = self.should_warn(error)\n\n        if not filename:\n            filename = fileinput.filename()\n        if not filelineno:\n            filelineno = fileinput.filelineno()\n        if warn:\n            self.warning_count = self.warning_count + 1\n        else:\n            self.error_count = self.error_count + 1\n\n        self.log_error(error, line, filename, filelineno, warn)\n\n    def log_error(self, error, line, filename, filelineno, warn=False):\n        # following pycodestyle/pep8 default output format\n        # https://github.com/PyCQA/pycodestyle/blob/master/pycodestyle.py#L108\n        print(\"%(filename)s:%(filelineno)s:1: %(error)s\" %\n              {'filename': filename,\n               'filelineno': filelineno,\n               'error': error.replace(\":\", \"\", 1)})\n\n    def check_files(self, files, verbose, max_line_length=79):\n        logical_line = \"\"\n        token = False\n\n        # NOTE(mrodden): magic; replace with proper\n        # report class when necessary\n        report = self\n\n        for fname in files:\n\n            # reset world\n            in_heredoc = False\n            in_continuation = False\n\n            # simple syntax checking, as files can pass style but still cause\n            # syntax errors when you try to run them.\n            check_syntax(fname, report)\n\n            for line in fileinput.input(fname):\n                if fileinput.isfirstline():\n\n                    check_hashbang(line, fileinput.filename(), report)\n\n                    if verbose:\n                        print(\"Running bashate on %s\" % fileinput.filename())\n\n                # Don't run any tests on comment lines (but remember\n                # inside a heredoc this might be part of the syntax of\n                # an embedded script, just ignore that)\n                if line.lstrip().startswith('#') and not in_heredoc:\n                    logical_line = [line]\n                    check_indents(logical_line, report)\n                    continue\n\n                # Strip trailing comments. From bash:\n                #\n                #   a word beginning with # causes that word and all\n                #   remaining characters on that line to be ignored.\n                #   ...\n                #   A character that, when unquoted, separates\n                #   words. One of the following: | & ; ( ) < > space\n                #   tab\n                #\n                # for simplicity, we strip inline comments by\n                # matching just '<space>#'.\n                if not in_heredoc:\n                    ll_split = line.split(' #', 1)\n                    if len(ll_split) > 1:\n                        line = ll_split[0].rstrip()\n\n                # see if this starts a heredoc\n                if not in_heredoc:\n                    token = starts_heredoc(line)\n                    if token:\n                        in_heredoc = True\n                        logical_line = [line]\n                        continue\n\n                # see if this starts a continuation\n                if not in_continuation:\n                    if is_continuation(line):\n                        in_continuation = True\n                        logical_line = [line]\n                        continue\n\n                # if we are in a heredoc or continuation, just loop\n                # back and keep buffering the lines into\n                # \"logical_line\" until the end of the\n                # heredoc/continuation.\n                if in_heredoc:\n                    logical_line.append(line)\n                    if not end_of_heredoc(line, token):\n                        continue\n                    else:\n                        in_heredoc = False\n                        # FIXME: if we want to do something with\n                        # heredocs in the future, then the whole thing\n                        # is now stored in logical_line.  for now,\n                        # skip\n                        continue\n                elif in_continuation:\n                    logical_line.append(line)\n                    if is_continuation(line):\n                        continue\n                    else:\n                        in_continuation = False\n                else:\n                    logical_line = [line]\n\n                check_indents(logical_line, report)\n\n                # at this point, logical_line is an array that holds\n                # the whole continuation.  XXX : historically, we've\n                # just handled every line in a continuation\n                # separatley.  Stick with what works...\n                for line in logical_line:\n                    check_no_trailing_whitespace(line, report)\n                    check_no_long_lines(line, report, max_line_length)\n                    check_for_do(line, report)\n                    check_if_then(line, report)\n                    check_function_decl(line, report)\n                    check_arithmetic(line, report)\n                    check_local_subshell(line, report)\n                    check_bare_arithmetic(line, report)\n                    check_conditional_expression(line, report)\n\n        # finished processing the file\n\n        # last line should always end with a newline\n        if not line.endswith('\\n'):\n            report.print_error(MESSAGES['E004'].msg, line)\n\n\ndef main(args=None):\n\n    if args is None:\n        args = sys.argv[1:]\n\n    parser = argparse.ArgumentParser(\n        description='A bash script style checker')\n    parser.add_argument('files', metavar='file', nargs='*',\n                        help='files to scan for errors')\n    parser.add_argument('-i', '--ignore', help='Rules to ignore')\n    parser.add_argument('-w', '--warn',\n                        help='Rules to always warn (rather than error)')\n    parser.add_argument('-e', '--error',\n                        help='Rules to always error (rather than warn)')\n    parser.add_argument('--max-line-length', default=79, type=int,\n                        help='Max line length')\n    parser.add_argument('-v', '--verbose', action='store_true', default=False)\n    parser.add_argument('--version', action='store_true',\n                        help='show bashate version number and exit',\n                        default=False)\n    parser.add_argument('-s', '--show', action='store_true', default=False)\n    opts = parser.parse_args(args)\n\n    if opts.version:\n        print(\"bashate: %s\" % bashate.__version__)\n        sys.exit(0)\n\n    if opts.show:\n        messages.print_messages()\n        sys.exit(0)\n\n    files = opts.files\n    if not files:\n        parser.print_usage()\n        return 1\n\n    run = BashateRun()\n    run.register_ignores(opts.ignore)\n    run.register_warnings(opts.warn)\n    run.register_errors(opts.error)\n\n    try:\n        run.check_files(files, opts.verbose, opts.max_line_length)\n    except IOError as e:\n        print(\"bashate: %s\" % e)\n        return 1\n\n    if run.warning_count > 0:\n        print(\"%d bashate warning(s) found\" % run.warning_count)\n\n    if run.error_count > 0:\n        print(\"%d bashate error(s) found\" % run.error_count)\n        return 1\n\n    return 0\n\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n"
  },
  {
    "path": "bashate/messages.py",
    "content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n# License for the specific language governing permissions and limitations\n# under the License.\n\nimport re\nimport textwrap\n\n\nclass _Message(object):\n    \"\"\"An individual bashate message.\n\n    This should be accessed via the MESSAGES dict keyed by msg_id,\n    e.g.\n\n      from bashate.messages import MESSAGES\n      print(MESSAGES['E123'].msg)\n\n    :param msg_id: The unique message id (E...)\n    :param msg_str: The short message string, as displayed in program\n                     output\n    :param long_msg: A longer more involved message, designed for\n                     documentation\n    \"\"\"\n    def __init__(self, msg_id, msg_str, long_msg, default):\n        self.msg_id = msg_id\n        self.msg_str = msg_str\n        # clean-up from \"\"\" to a plain string\n        if long_msg:\n            self.long_msg = textwrap.dedent(long_msg)\n            self.long_msg = self.long_msg.strip()\n        else:\n            self.long_msg = None\n        self.default = default\n\n    @property\n    def msg(self):\n        # For historical reasons, the code relies on \"id: msg\" so build\n        # that up as .msg property for quick access.\n        return \"%s: %s\" % (self.msg_id, self.msg_str)\n\n\n_messages = {\n    'E001': {\n        'msg': 'Trailing Whitespace',\n        'long_msg': None,\n        'default': 'E'\n    },\n    'E002': {\n        'msg': 'Tab indents',\n        'long_msg':\n        \"\"\"\n        Spaces are preferred to tabs in source files.\n        \"\"\",\n        'default': 'E'\n    },\n    'E003': {\n        'msg': 'Indent not multiple of 4',\n        'long_msg':\n        \"\"\"\n        Four spaces should be used to offset logical blocks.\n        \"\"\",\n        'default': 'E'\n    },\n    'E004': {\n        'msg': 'File did not end with a newline',\n        'long_msg':\n        \"\"\"\n        It is conventional to have a single newline ending files.\n        \"\"\",\n        'default': 'E'\n    },\n    'E005': {\n        'msg': 'File does not begin with #! or have .sh prefix',\n        'long_msg':\n        \"\"\"\n        This can be useful for tools that use either the interpreter\n        directive or the file-exension to select highlighting mode,\n        syntax mode or determine MIME-type, such as file, gerrit and\n        editors.\n        \"\"\",\n        'default': 'W'\n    },\n    'E006': {\n        'msg': 'Line too long',\n        'long_msg':\n        \"\"\"\n        This check mimics the widely accepted convention from PEP8 and\n        many other places that lines longer than a standard terminal width\n        (default=79 columns) can not only cause problems when reading/writing\n        code, but also often indicates a bad smell, e.g. too many levels\n        of indentation due to overly complex functions which require\n        refactoring into smaller chunks.\n        \"\"\",\n        'default': 'W'\n    },\n    'E010': {\n        'msg': 'The \"do\" should be on same line as %s',\n        'long_msg':\n        \"\"\"\n        Ensure consistency of \"do\" directive being on the same line as\n        it's command.  For example:\n\n           for i in $(seq 1 100);\n           do\n              echo \"hi\"\n           done\n\n        will trigger this error\n        \"\"\",\n        'default': 'E'\n    },\n    'E011': {\n        'msg': 'Then keyword is not on same line as if or elif keyword',\n        'long_msg':\n        \"\"\"\n        Similar to E010, this ensures consistency of if/elif statements\n        \"\"\",\n        'default': 'E'\n    },\n    'E012': {\n        'msg': 'here-document at line %d delimited by end-of-file',\n        'long_msg':\n        \"\"\"\n        This check ensures the closure of heredocs (<<EOF directives).\n        Bash will warn when a heredoc is delimited by end-of-file, but\n        it is easily missed and can cause unexpected issues when a\n        file is sourced.\n        \"\"\",\n        'default': 'E'\n    },\n    'E020': {\n        'msg': 'Function declaration not in format ^function name {$',\n        'long_msg':\n        \"\"\"\n        There are several equivalent ways to define functions in Bash.\n        This check is for consistency.\n        \"\"\",\n        'default': 'E'\n    },\n    'E040': {\n        'msg': 'Syntax error',\n        'long_msg':\n        \"\"\"\n        `bash -n` determined that there was a syntax error preventing\n        the script from parsing correctly and running.\n        \"\"\",\n        'default': 'E'\n    },\n    'E041': {\n        'msg': 'Arithmetic expansion using $[ is deprecated for $((',\n        'long_msg':\n        \"\"\"\n        $[ is deprecated and not explained in the Bash manual.  $((\n        should be used for arithmetic.\n        \"\"\",\n        'default': 'E'\n    },\n    'E042': {\n        'msg': 'local declaration hides errors',\n        'long_msg':\n        \"\"\"\n        The return value of \"local\" is always 0; errors in subshells\n        used for declaration are thus hidden and will not trigger \"set -e\".\n        \"\"\",\n        'default': 'W',\n    },\n    'E043': {\n        'msg': 'Arithmetic compound has inconsistent return semantics',\n        'long_msg':\n        \"\"\"\n        The return value of ((expr)) is 1 if \"expr\" evalues to zero,\n        otherwise 0.  Combined with \"set -e\", this can be quite\n        confusing when something like ((counter++)) evaluates to zero,\n        making the arithmetic evaluation return 1 and triggering the\n        an error failure.  It is therefore best to use assignment with\n        the $(( operator.\n        \"\"\",\n        'default': 'W',\n    },\n    'E044': {\n        'msg': 'Use [[ for non-POSIX comparisions',\n        'long_msg':\n        \"\"\"\n        [ is the POSIX test operator, while [[ is the bash keyword\n        comparision operator.  Comparisons such as =~, < and > require\n        the use of [[.\n        \"\"\",\n        'default': 'E',\n    },\n}\n\nMESSAGES = {}\n\n_default_errors = []\n_default_warnings = []\n\nfor k, v in _messages.items():\n    MESSAGES[k] = _Message(k, v['msg'], v['long_msg'], v['default'])\n\n    if v['default'] == 'E':\n        _default_errors.append(k)\n    if v['default'] == 'W':\n        _default_warnings.append(k)\n\n# convert this to the regex strings.  This looks a bit weird\n# but it fits the current model of error/warning/ignore checking\n# easily.\n_default_errors = '^(' + '|'.join(_default_errors) + ')'\n_default_warnings = '^(' + '|'.join(_default_warnings) + ')'\n\n\ndef is_default_error(error):\n    return re.search(_default_errors, error)\n\n\ndef is_default_warning(error):\n    return re.search(_default_warnings, error)\n\n\ndef print_messages():\n\n    print(\"\\nAvailable bashate checks\")\n    print(\"------------------------\\n\")\n    for k, v in MESSAGES.items():\n        print(\" [%(default)s] %(id)s : %(string)s\" % {\n            'default': v.default,\n            'id': v.msg_id,\n            'string': v.msg_str})\n        if v.long_msg:\n            for msg_line in v.long_msg.split('\\n'):\n                print(\"            %s\" % msg_line)\n        print(\"\")\n"
  },
  {
    "path": "bashate/tests/__init__.py",
    "content": ""
  },
  {
    "path": "bashate/tests/base.py",
    "content": "# Copyright 2010-2011 OpenStack Foundation\n# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the License. You may obtain\n# a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n# License for the specific language governing permissions and limitations\n# under the License.\n\nimport os\n\nimport fixtures\nimport testtools\n\n_TRUE_VALUES = ('True', 'true', '1', 'yes')\n\n\nclass TestCase(testtools.TestCase):\n    \"\"\"Test case base class for all unit tests.\"\"\"\n\n    def setUp(self):\n        \"\"\"Run before each test method to initialize test environment.\"\"\"\n\n        super(TestCase, self).setUp()\n        test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)\n        try:\n            test_timeout = int(test_timeout)\n        except ValueError:\n            # If timeout value is invalid do not set a timeout.\n            test_timeout = 0\n        if test_timeout > 0:\n            self.useFixture(fixtures.Timeout(test_timeout, gentle=True))\n\n        self.useFixture(fixtures.NestedTempfile())\n        self.useFixture(fixtures.TempHomeDir())\n\n        if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES:\n            stdout = self.useFixture(fixtures.StringStream('stdout')).stream\n            self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))\n        if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES:\n            stderr = self.useFixture(fixtures.StringStream('stderr')).stream\n            self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))\n\n        self.log_fixture = self.useFixture(fixtures.FakeLogger())\n"
  },
  {
    "path": "bashate/tests/samples/.E005_excluded",
    "content": "# this profile/hidden file doesn't start with #!\n# and doesn't have a .sh extension\n\necho hi\n"
  },
  {
    "path": "bashate/tests/samples/E001_bad.sh",
    "content": "#!/bin/bash\n\n# E001\nsomefunction args  \n"
  },
  {
    "path": "bashate/tests/samples/E002_bad.sh",
    "content": "#!/bin/bash\n\n\techo \"E002: Has a tab\"\n"
  },
  {
    "path": "bashate/tests/samples/E003_bad.sh",
    "content": "#!/bin/bash\n\nthis is \\\n      bad continuation as it does not match 1st arg or %4\n\na \\\n bad indent\n\nif foo; then\n    testing a \\\n  bad indent, indented\nfi\n"
  },
  {
    "path": "bashate/tests/samples/E003_good.sh",
    "content": "#!/bin/bash\n\nthis is \\\n     a continuation \\\n     where the continued lines \\\n     align with the first argument\n\na \\\n    is a continuation where there is no \\\n    argument so we line-up to the default \\\n    4 spaces\n\nif foo; then\n\n    testing a \\\n            continuation indented\nfi\n"
  },
  {
    "path": "bashate/tests/samples/E004_bad.sh",
    "content": "this file\nhas no\nnewline at end"
  },
  {
    "path": "bashate/tests/samples/E005_bad",
    "content": "# this file doesn't start with #!\n# and doesn't have a .sh extension\n\necho hi\n"
  },
  {
    "path": "bashate/tests/samples/E006_bad.sh",
    "content": "#!/bin/bash\n\n# lines longer than 79 columns\n\n: 345678901234567890123456789012345678901234567890123456789012345678901234567890\n:        1         2         3         4         5         6         7         8\n# next line goes over by virtue of trailing whitespace\n:        1         2         3         4         5         6         7          \n"
  },
  {
    "path": "bashate/tests/samples/E006_bad_custom_length.sh",
    "content": "#!/bin/bash\n\n# lines longer than 10 columns give warnings\n\n: 0123456789\n:        1         2         3         4         5         6         7         8\n\n: 012345\n"
  },
  {
    "path": "bashate/tests/samples/E006_good.sh",
    "content": "#!/bin/bash\n\n# Allow lines 79 columns or shorter\n\n: 34567890123456789012345678901234567890123456789012345678901234567890123456789\n:        1         2         3         4         5         6         7\n\n# and make sure we allow continuation lines >= 80 columns which are comprised\n# of physical lines which are all <= 79 columns.\necho 678901234567890123456789012345678901234567890123456789012345678901234567 \\\n    567890123456789012345678901234567890123456789012345678901234567890123456789\n"
  },
  {
    "path": "bashate/tests/samples/E010_bad.sh",
    "content": "#!/bin/bash\n\nwhile [ 0 ]\ndo\n    zero\ndone\n\n# for do done in one line\nfor [ 0 ]; do run_morethings; done\n"
  },
  {
    "path": "bashate/tests/samples/E010_good.sh",
    "content": "#!/bin/bash\n\n# E010 good\nwhile [ 0 ]; do\n    run_things\ndone\n\n# E010 with comment\nwhile [ 0 ]; do # comment\n    run_things\ndone\n"
  },
  {
    "path": "bashate/tests/samples/E011_bad.sh",
    "content": "#!/bin/bash\n\nif [ 0 ]\nthen\n    zero\nelif [ 1 ]\nthen\n    one\nelse\n    default\nfi\n\n# if else fi in one line\nif [ 0 ]; then run_morethings; else run_otherthings; fi\n"
  },
  {
    "path": "bashate/tests/samples/E011_good.sh",
    "content": "#!/bin/bash\n\n# E011 good\nif [ 0 ]; then\n    run_morethings\nelse\n    run_otherthings\nfi\n\n# E011 with comment\nif [ 0 ]; then # comment\n    run_morethings\nfi\n"
  },
  {
    "path": "bashate/tests/samples/E012_bad.sh",
    "content": "#unexpected end-of-file on this\nif foo; then\n\nFOO=<<EOF\nblah foo moo\n\n\n# heredoc not ending\n\n"
  },
  {
    "path": "bashate/tests/samples/E040_syntax_error.sh",
    "content": "#!/bin/bash\n\nfunction myfn {\n    if [ '' == '' ]; then\n        echo 'Things'\n    fii\n}\n"
  },
  {
    "path": "bashate/tests/samples/E041_bad.sh",
    "content": "#!/bin/bash\n\n# E021\nfoo=$[ 1 + 1 ]\n"
  },
  {
    "path": "bashate/tests/samples/E042_bad.sh",
    "content": "function hello {\n    local foo=$(ls)\n}\n\nfunction hello_too {\n    local foo=`ls`\n}\n\nfunction hello_with_quotes {\n    local foo=\"$(ls)\"\n    local bar=\"`ls`\"\n}\n\nhello\nhello_too\n"
  },
  {
    "path": "bashate/tests/samples/E043_bad.sh",
    "content": "count=0\nthings=\"0 1 0 0 1\"\n\nfor i in $things; do\n    if [ $i == \"1\" ]; then\n        (( count++ ))\n    fi\ndone\n\necho \"Count is ${count}\"\n"
  },
  {
    "path": "bashate/tests/samples/E044_bad.sh",
    "content": "# =~\n\nif [ \"test\" =~ \"]\" ]; then\n    echo \"Does not work!\"\nfi\n\n[ \"test\" =~ \"string\" ] && echo \"Does not work!\"\n\nif [[ $foo == bar || \"test\" =~ \"[\" ]]; then\n    echo \"Does work!\"\nfi\n\n[[ \"test\" =~ \"string\" ]] && echo \"Does work\"\n\n# <\n\nif [ 1 < '2' ]; then\n    echo \"Does not work!\"\nfi\n\n[ 1 < 2 ] && echo \"Does not work!\"\n\nif [[ 1 < 2 ]]; then\n    echo \"Does work!\"\nfi\n\n[[ 1 < 2 ]] && echo \"Does work\"\n\n# >\n\nif [ 1 > 2 ]; then\n    echo \"Does not work!\"\nfi\n\n[ 1 > 2 ] && echo \"Does not work!\"\n\nif [[ 1 > 2 ]]; then\n    echo \"Does work!\"\nfi\n\n[[ 1 > 2 ]] && echo \"Does work\"\n"
  },
  {
    "path": "bashate/tests/samples/comments.sh",
    "content": "#!/bin/bash\n\n# make sure we're ignoring comments correctly\n\n## multiple\n\n# if [ foo ];\n# then\n#  echo \"blah\"\n# fi\n\nfoo=1 # `test`\n\nif [ foo ]; then # hello\n    echo \"hi\"\nfi\n\nif [ foo ]; then ## hello ##\n    echo \"hi\"\nfi\n\n# ``RST style comment``\n\n # ``indented comment`` (E003)\n\n    # ``indented comment`` (4 spaces, ok)\n\n\t# ``indented comment`` (tab, E002)\n\n#\ttab comment\n"
  },
  {
    "path": "bashate/tests/samples/for_loops.sh",
    "content": "# for loop examples\n\n# pass\nfor i in $(seq 1 5); do\n    echo $i\ndone\n\n# pass\nfor (( i = 0 ; i < 5 ; i++ )); do\n    echo $i\ndone\n\n# fail E010\nfor i in $(seq 1 5);\ndo\n    echo $i\ndone\n\n# fail E010\nfor (( i = 0 ; i < 5 ; i++ ));\ndo\n    echo $i\ndone\n\n# should ignore \"for (\" [note single parenthesis] as it is likely awk\nawk '{\n    for (i = 1; i < 5; i++)\n        print $i\n}' < /dev/null\n"
  },
  {
    "path": "bashate/tests/samples/heredoc_ignore.sh",
    "content": "#!/bin/bash\n\nFOO=<<EOF\n\n this is a file\n  that does not obey our indenting\n or our line length -------------------------------------------------\n\nEOF\n\ncat <<EOF > /tmp/tofile\n\n this is a file\n  that does not obey our indenting\n or our line length -------------------------------------------------\n\nEOF\n\ncat << 'EOF' | sed 's/foo/bar'\n\n this is a file\n  that does not obey our indenting\n or our line length -------------------------------------------------\n\nEOF\n\ncat <<\"EOF\"\n\n this is a file\n  that does not obey our indenting\n or our line length -------------------------------------------------\n\nEOF\n\ncat > foo <<BLAH\n\n this is a file\n  that does not obey our indenting\n or our line length -------------------------------------------------\n\n\nBLAH\n"
  },
  {
    "path": "bashate/tests/samples/legacy_sample.sh",
    "content": "#!/bin/bash\n# E020\nfunction somefunction () {\n\techo \"E002: Has a tab\"\n\n  echo \"E003: Not an indent with multiple of 4\"\n}\n\n# E001\nsomefunction args  \n\n# E010\nfor thing in things\ndo\n    run_things thing\ndone\n\nwhile 0\ndo\n    run_thing\ndone\n\nuntil 1\ndo\n    run_thing\ndone\n\n# E011\nif [ 0 ]\nthen\n    run_morethings\nelse\n    run_otherthings\nfi\n\n# E012\ncat <<EOH\nthis heredoc is bad\n\n# E004"
  },
  {
    "path": "bashate/tests/test_bashate.py",
    "content": "# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the License. You may obtain\n# a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n# License for the specific language governing permissions and limitations\n# under the License.\n\n\"\"\"\ntest_bashate\n----------------------------------\n\nTests for `bashate` module.\n\"\"\"\n\nfrom unittest import mock\n\nfrom bashate import bashate\nfrom bashate import messages\nfrom bashate.tests import base\n\n\nMESSAGES = messages.MESSAGES\n\n\nclass TestBashate(base.TestCase):\n\n    def setUp(self):\n        super(TestBashate, self).setUp()\n        self.run = bashate.BashateRun()\n\n    @mock.patch('bashate.bashate.BashateRun')\n    def test_main_no_files(self, m_bashaterun):\n        m_run_obj = mock.MagicMock()\n        m_run_obj.error_count = 0\n        m_run_obj.warning_count = 0\n        m_bashaterun.return_value = m_run_obj\n\n        result = bashate.main([])\n        expected_return = 1\n        self.assertEqual(expected_return, result)\n\n    @mock.patch('bashate.bashate.BashateRun')\n    def test_main_return_one_on_errors(self, m_bashaterun):\n        m_run_obj = mock.MagicMock()\n        m_run_obj.warning_count = 1\n        m_run_obj.error_count = 1\n        m_bashaterun.return_value = m_run_obj\n\n        result = bashate.main([])\n        expected_return = 1\n        self.assertEqual(expected_return, result)\n\n    @mock.patch('bashate.bashate.BashateRun')\n    def test_main_return_one_on_ioerror(self, m_bashaterun):\n        m_run_obj = mock.MagicMock()\n        m_run_obj.error_count = 0\n        m_run_obj.check_files = mock.Mock(side_effect=IOError)\n        m_bashaterun.return_value = m_run_obj\n\n        result = bashate.main(['--verbose',\n                               '/path/to/fileA', '/path/to/fileB'])\n        m_run_obj.check_files.assert_called_with(\n            ['/path/to/fileA', '/path/to/fileB'],\n            True,\n            79\n        )\n        expected_return = 1\n        self.assertEqual(expected_return, result)\n\n    def test_multi_ignore_with_slash(self):\n        self.run.register_ignores('E001|E011')\n        bashate.check_no_trailing_whitespace(\"if \", self.run)\n        bashate.check_if_then(\"if \", self.run)\n\n        self.assertEqual(0, self.run.error_count)\n\n    def test_multi_ignore_with_comma(self):\n        self.run.register_ignores('E001,E011')\n        bashate.check_no_trailing_whitespace(\"if \", self.run)\n        bashate.check_if_then(\"if \", self.run)\n\n        self.assertEqual(0, self.run.error_count)\n\n    def test_multi_ignore_mixed(self):\n        self.run.register_ignores('E001|E002,E003|E011')\n        bashate.check_no_trailing_whitespace(\"if \", self.run)\n        bashate.check_if_then(\"if \", self.run)\n        bashate.check_indents(\"  echo\", self.run)\n\n        self.assertEqual(0, self.run.error_count)\n\n    def test_ignore(self):\n        self.run.register_ignores('E001')\n        bashate.check_no_trailing_whitespace(\"if \", self.run)\n\n        self.assertEqual(0, self.run.error_count)\n\n    @mock.patch('bashate.bashate.BashateRun.print_error')\n    def test_while_check_for_do(self, m_print_error):\n        test_line = 'while `do something args`'\n        bashate.check_for_do(test_line, self.run)\n\n        m_print_error.assert_called_once_with(\n            MESSAGES['E010'].msg % 'while', test_line)\n\n\nclass TestBashateSamples(base.TestCase):\n    \"\"\"End to end regression testing of bashate against script samples.\"\"\"\n\n    def setUp(self):\n        super(TestBashateSamples, self).setUp()\n        log_error_patcher = mock.patch(\n            'bashate.bashate.BashateRun.log_error')\n        self.m_log_error = log_error_patcher.start()\n        self.run = bashate.BashateRun()\n        self.addCleanup(log_error_patcher.stop)\n\n    def assert_error_found(self, error, lineno):\n        error_found = False\n        for call in self.m_log_error.call_args_list:\n            # unwrap args\n            args = call[0]\n            if (args[0].startswith(error) and lineno == args[3]):\n                error_found = True\n        if not error_found:\n            self.fail('Error %s expected at line %d not found!' %\n                      (error, lineno))\n\n    def test_sample_E001(self):\n        test_files = ['bashate/tests/samples/E001_bad.sh']\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E001', 4)\n\n    def test_sample_E002(self):\n        test_files = ['bashate/tests/samples/E002_bad.sh']\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E002', 3)\n\n    def test_sample_E003(self):\n        test_files = ['bashate/tests/samples/E003_good.sh']\n        self.run.check_files(test_files, False)\n        self.assertEqual(0, self.run.error_count)\n\n    def test_sample_E003_bad(self):\n        test_files = ['bashate/tests/samples/E003_bad.sh']\n        self.run.check_files(test_files, False)\n        self.assert_error_found('E003', 4)\n        self.assert_error_found('E003', 7)\n        self.assert_error_found('E003', 11)\n\n    def test_sample_E004_bad(self):\n        test_files = ['bashate/tests/samples/E004_bad.sh']\n        self.run.check_files(test_files, False)\n        self.assert_error_found('E004', 3)\n\n    def test_sample_E006_bad(self):\n        test_files = ['bashate/tests/samples/E006_bad.sh']\n        self.run.check_files(test_files, False)\n\n        self.assertEqual(self.run.warning_count, 3)\n        self.assert_error_found('E006', 5)\n        self.assert_error_found('E006', 6)\n        self.assert_error_found('E006', 8)\n\n    def test_sample_E006_bad_ignore_trailing_ws(self):\n        self.run.register_ignores('E001')\n        test_files = ['bashate/tests/samples/E006_bad.sh']\n        self.run.check_files(test_files, False)\n\n        self.assertEqual(self.run.warning_count, 3)\n        self.assert_error_found('E006', 5)\n        self.assert_error_found('E006', 6)\n        self.assert_error_found('E006', 8)\n\n    def test_sample_E006_bad_custom_max_line_length(self):\n        test_files = ['bashate/tests/samples/E006_bad_custom_length.sh']\n        self.run.check_files(test_files, False, 10)\n\n        self.assertEqual(self.run.warning_count, 2)\n        self.assert_error_found('E006', 5)\n        self.assert_error_found('E006', 6)\n\n    def test_sample_E006_good(self):\n        test_files = ['bashate/tests/samples/E006_good.sh']\n        self.run.check_files(test_files, False)\n\n        self.assertEqual(self.run.warning_count, 0)\n\n    def test_sample_E010_good(self):\n        test_files = ['bashate/tests/samples/E010_good.sh']\n        self.run.check_files(test_files, False)\n\n        self.assertEqual(self.run.error_count, 0)\n\n    def test_sample_E010(self):\n        test_files = ['bashate/tests/samples/E010_bad.sh']\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E010', 3)\n        self.assert_error_found('E010', 9)\n\n    def test_sample_E011_good(self):\n        test_files = ['bashate/tests/samples/E011_good.sh']\n        self.run.check_files(test_files, False)\n\n        self.assertEqual(self.run.error_count, 0)\n\n    def test_sample_E011(self):\n        test_files = ['bashate/tests/samples/E011_bad.sh']\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E011', 3)\n        self.assert_error_found('E011', 6)\n\n    def test_sample_E012(self):\n        test_files = ['bashate/tests/samples/E012_bad.sh']\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E012', 9)\n        self.assert_error_found('E040', 10)\n\n    def test_sample_E041(self):\n        test_files = ['bashate/tests/samples/E041_bad.sh']\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E041', 4)\n\n    def test_sample_E042(self):\n        test_files = ['bashate/tests/samples/E042_bad.sh']\n        self.run.register_errors('E042')\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E042', 2)\n        self.assert_error_found('E042', 6)\n        self.assert_error_found('E042', 10)\n        self.assert_error_found('E042', 11)\n\n    def test_sample_E043(self):\n        test_files = ['bashate/tests/samples/E043_bad.sh']\n        self.run.register_errors('E043')\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E043', 6)\n\n    def test_sample_for_loops(self):\n        test_files = ['bashate/tests/samples/for_loops.sh']\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E010', 14)\n        self.assert_error_found('E010', 20)\n\n    def test_sample_comments(self):\n        test_files = ['bashate/tests/samples/comments.sh']\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E003', 24)\n        self.assert_error_found('E002', 28)\n        self.assert_error_found('E003', 28)\n        self.assertEqual(3, self.run.error_count)\n\n    def test_sample_E005(self):\n        test_files = ['bashate/tests/samples/E005_bad']\n        self.run.register_errors('E005')\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E005', 1)\n\n    def test_sample_E005_excluded(self):\n        test_files = ['bashate/tests/samples/.E005_excluded']\n        self.run.check_files(test_files, False)\n\n        self.assertEqual(0, self.run.error_count)\n\n    def test_sample_E040(self):\n        test_files = ['bashate/tests/samples/E040_syntax_error.sh']\n        self.run.register_errors('E040')\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E040', 7)\n\n    def test_sample_E044(self):\n        test_files = ['bashate/tests/samples/E044_bad.sh']\n        self.run.check_files(test_files, False)\n\n        self.assert_error_found('E044', 3)\n        self.assert_error_found('E044', 7)\n        self.assert_error_found('E044', 17)\n        self.assert_error_found('E044', 21)\n        self.assert_error_found('E044', 31)\n        self.assert_error_found('E044', 35)\n\n    def test_sample_warning(self):\n        # reuse a couple of the above files to make sure we turn\n        # errors down to warnings if requested\n        test_files = ['bashate/tests/samples/E011_bad.sh',\n                      'bashate/tests/samples/E041_bad.sh']\n        self.run.register_warnings('E011,E041')\n        self.run.check_files(test_files, False)\n\n        self.assertEqual(0, self.run.error_count)\n        self.assertEqual(4, self.run.warning_count)\n\n    def test_ignore_heredoc(self):\n        test_files = ['bashate/tests/samples/heredoc_ignore.sh']\n        self.run.check_files(test_files, False)\n        self.assertEqual(0, self.run.error_count)\n\n    def test_pre_zero_dot_one_sample_file(self):\n        \"\"\"Test the sample file with all pre 0.1.0 release checks.\n\n        This is a legacy compatibility check to make sure we still\n        catch the same errors as we did before the first 0.1.0\n        release of the bashate pypi package. There were no tests\n        before this, so it is our baseline regression check.\n\n        New checks shouldn't need to be added here, and should\n        have their own separate unit test and/or sample file checks.\n        \"\"\"\n\n        test_files = ['bashate/tests/samples/legacy_sample.sh']\n        self.run.check_files(test_files, False)\n\n        expected_errors = [\n            ('E002', 4),\n            ('E003', 6),\n            ('E001', 10),\n            ('E010', 13),\n            ('E010', 18),\n            ('E010', 23),\n            ('E011', 29),\n            ('E020', 3)\n        ]\n\n        for error in expected_errors:\n            self.assert_error_found(*error)\n"
  },
  {
    "path": "bindep.txt",
    "content": "# This is a cross-platform list tracking distribution packages needed by tests;\n# see http://docs.openstack.org/infra/bindep/ for additional information.\n# PDF Docs package dependencies\ntex-gyre [doc platform:dpkg]\n"
  },
  {
    "path": "doc/requirements.txt",
    "content": "# The order of packages is significant, because pip processes them in the order\n# of appearance. Changing the order has an impact on the overall integration\n# process, which may cause wedges in the gate later.\n\nsphinx>=2.0.0,!=2.1.0 # BSD\nopenstackdocstheme>=2.2.1 # Apache-2.0\nreno>=3.1.0 # Apache-2.0\n"
  },
  {
    "path": "doc/source/conf.py",
    "content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n# implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os\nimport sys\n\nsys.path.insert(0, os.path.abspath('../..'))\n# -- General configuration ----------------------------------------------------\n\n# Add any Sphinx extension module names here, as strings. They can be\n# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.\nextensions = [\n    'sphinx.ext.autodoc',\n    #'sphinx.ext.intersphinx',\n    'openstackdocstheme',\n    'reno.sphinxext'\n]\n\n# autodoc generation is a bit aggressive and a nuisance when doing heavy\n# text edit cycles.\n# execute \"export SPHINX_DEBUG=1\" in your terminal to disable\n\n# The suffix of source filenames.\nsource_suffix = '.rst'\n\n# The master toctree document.\nmaster_doc = 'index'\n\n# General information about the project.\nproject = 'bashate'\ncopyright = '2017, Bashate Authors'\n\n# If true, '()' will be appended to :func: etc. cross-reference text.\nadd_function_parentheses = True\n\n# If true, the current module name will be prepended to all description\n# unit titles (such as .. function::).\nadd_module_names = True\n\n# The name of the Pygments (syntax highlighting) style to use.\npygments_style = 'native'\n\n# openstackdocstheme options\nopenstackdocs_repo_name = 'openstack-dev/bashate'\nopenstackdocs_bug_project = 'bashate'\nopenstackdocs_bug_tag = ''\nopenstackdocs_pdf_link = True\n\n# Grouping the document tree for man pages.\n# List of tuples 'sourcefile', 'target', 'title', 'Authors name', 'manual'\nman_pages = [\n    ('man/bashate', 'bashate', 'Style checker for bash scripts',\n     ['OpenStack Foundation'], 1),\n]\n\n\n# -- Options for HTML output --------------------------------------------------\n\n# The theme to use for HTML and HTML Help pages.  Major themes that come with\n# Sphinx are currently 'default' and 'sphinxdoc'.\n# html_theme = '_theme'\n# html_static_path = ['static']\n\nhtml_theme = 'openstackdocs'\n\n# Output file base name for HTML help builder.\nhtmlhelp_basename = '%sdoc' % project\n\n# Grouping the document tree into LaTeX files. List of tuples\n# (source start file, target name, title, author, documentclass\n# [howto/manual]).\nlatex_documents = [\n    ('index',\n     'doc-%s.tex' % project,\n     'Bashate Documentation',\n     'Bashate Authors', 'manual'),\n]\n\n# Example configuration for intersphinx: refer to the Python standard library.\n#intersphinx_mapping = {'http://docs.python.org/': None}\nlatex_use_xindy = False\nlatex_elements = {\n    'extraclassoptions': 'openany,oneside',\n}\n"
  },
  {
    "path": "doc/source/contributor/contributing.rst",
    "content": "============================\nSo You Want to Contribute...\n============================\n\nFor general information on contributing to OpenStack, please check out the\n`contributor guide <https://docs.openstack.org/contributors/>`_ to get started.\nIt covers all the basics that are common to all OpenStack projects: the accounts\nyou need, the basics of interacting with our Gerrit review system, how we\ncommunicate as a community, etc.\n\nBelow will cover the more project specific information you need to get started\nwith Bashate.\n\nCommunication\n~~~~~~~~~~~~~\n* IRC channel ``#openstack-qa`` at OFTC\n* Mailing list (prefix subjects with ``[qa]`` for faster responses)\n  http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-discuss\n\nContacting the Core Team\n~~~~~~~~~~~~~~~~~~~~~~~~\nPlease refer to the `Bashate Core Team\n<https://review.opendev.org/#/admin/groups/333,members>`_ contacts.\n\nNew Feature Planning\n~~~~~~~~~~~~~~~~~~~~\nIf you want to propose a new feature please read `Feature Proposal Process`_\n\nTask Tracking\n~~~~~~~~~~~~~\nWe track our tasks in `Launchpad <https://bugs.launchpad.net/bash8>`__.\n\nReporting a Bug\n~~~~~~~~~~~~~~~\nYou found an issue and want to make sure we are aware of it? You can do so on\n`Launchpad <https://bugs.launchpad.net/bash8/+filebug>`__.\nMore info about Launchpad usage can be found on `OpenStack docs page\n<https://docs.openstack.org/contributors/common/task-tracking.html#launchpad>`_\n\nGetting Your Patch Merged\n~~~~~~~~~~~~~~~~~~~~~~~~~\nAll changes proposed to the Bashate requires single ``Code-Review +2`` votes as minimum from\nBashate core reviewers who can approve patch by giving ``Workflow +1`` vote.\n\nProject Team Lead Duties\n~~~~~~~~~~~~~~~~~~~~~~~~\nAll common PTL duties are enumerated in the `PTL guide\n<https://docs.openstack.org/project-team-guide/ptl.html>`_.\n\nThe Release Process for QA is documented in `QA Release Process\n<https://wiki.openstack.org/wiki/QA/releases>`_.\n\n.. _Feature Proposal Process: https://wiki.openstack.org/wiki/QA#Feature_Proposal_.26_Design_discussions\n"
  },
  {
    "path": "doc/source/contributor/index.rst",
    "content": "============\nContributing\n============\n\n.. toctree::\n   :maxdepth: 2\n\n   contributing.rst\n"
  },
  {
    "path": "doc/source/index.rst",
    "content": "===================================\nWelcome to bashate's documentation!\n===================================\n\n.. toctree::\n   :maxdepth: 2\n\n   readme\n   install/index.rst\n   user/index.rst\n   contributor/index.rst\n\nIndices and tables\n==================\n\n* :ref:`genindex`\n* :ref:`modindex`\n* :ref:`search`\n"
  },
  {
    "path": "doc/source/install/index.rst",
    "content": "============\nInstallation\n============\n\nAt the command line::\n\n    $ pip install bashate\n\nOr, if you have virtualenvwrapper installed::\n\n    $ mkvirtualenv bashate\n    $ pip install bashate\n"
  },
  {
    "path": "doc/source/man/bashate.rst",
    "content": "===========================\n:program:`bashate` man page\n===========================\n\n.. program:: bashate\n.. highlight:: bash\n\nSYNOPSIS\n========\n\n:program:`bashate` [options] <file> [files...]\n\nDESCRIPTION\n===========\n\nThe :program:`bashate` command line utility is a style-checker for\nbash scripts.\n\nThe name is derived from :program:`pep8`, a Python lint-type tool.\n\nOPTIONS\n=======\n\n--help, -h        Print help\n--verbose, -v     Verbose output\n--ignore, -i      Tests to ignore, comma separated\n--error, -e       Tests to trigger errors instead of warnings, comma separated\n--warn, -w        Tests to trigger warnings instead of errors, comma separated\n\nEXAMPLES\n========\n\nRun all tests on a single file::\n\n    bashate file.sh\n\nRun tests on several files, while also ignoring several errors::\n\n    bashate -i E010,E011 file.sh file2.sh\n\nBUGS\n====\n\nhttp://bugs.launchpad.net/bash8\n"
  },
  {
    "path": "doc/source/readme.rst",
    "content": ".. include:: ../../README.rst\n\nSee also\n~~~~~~~~\n\nSee also :doc:`/man/bashate`.\n"
  },
  {
    "path": "doc/source/user/index.rst",
    "content": "=============\nUsing bashate\n=============\n\n.. toctree::\n   :maxdepth: 2\n\n   usage.rst\n   ../man/bashate.rst\n\n"
  },
  {
    "path": "doc/source/user/usage.rst",
    "content": "========\nUsage\n========\n\nTo use bashate in a project::\n\n\timport bashate\n"
  },
  {
    "path": "playbooks/bashate-devstack-master/run.yaml",
    "content": "- hosts: all\n  name: Run bashate against devstack master\n  roles:\n    - bindep\n    - role: ensure-tox\n      ensure_global_symlinks: true\n\n  tasks:\n    - shell: 'tox -e bashate'\n      args:\n        executable: /bin/bash\n        chdir: '{{ ansible_user_dir }}/{{ zuul.projects[\"opendev.org/openstack/devstack\"].src_dir }}'\n      environment:\n        BASHATE_INSTALL_PATH: 'file://{{ ansible_user_dir }}/{{ zuul.project.src_dir }}'\n\n"
  },
  {
    "path": "releasenotes/notes/0-dash-6-748e729ee001df73.yaml",
    "content": "---\nfeatures:\n  - Python 3.6 support added\n  - Hidden files such as ``.bashrc`` are no longer checked for ``#!`` (E005)\n  - A basic check for ``[[`` when using non-POSIX comparisions such as\n    ``=~`` is added\n  - Enable bashate to be called as a module ``python -m bashate ...``\n  - Enable `pre-commit.com <https://pre-commit.com>`__ support"
  },
  {
    "path": "releasenotes/notes/adopt-pycodestyle-output-format-f4d6e35dadfcb6f9.yaml",
    "content": "---\nfeatures:\n  - |\n    Adoped pycodestyle/pep8 default output format.\n"
  },
  {
    "path": "releasenotes/notes/custom-line-length-083e8077951a8ead.yaml",
    "content": "---\nfeatures:\n  - |\n    Adds an option ``--max-line-length`` to specify the maximum length\n    of lines for check E006.\n"
  },
  {
    "path": "releasenotes/notes/drop-python2.7-064c5e5bcfb4539c.yaml",
    "content": "---\ndeprecations:\n  - |\n    bashate is now Python 3 only and no longer supports Python 2."
  },
  {
    "path": "releasenotes/notes/heredoc-ignore-905b29053652f90e.yaml",
    "content": "---\nfixes:\n\n  - Ignore contents of ``heredoc`` values.  ``heredocs`` usually\n    contain content in a foreign syntax so ``bashate`` will no longer\n    consider them.\n\n  - Continuation lines are now parsed into an array, rather than a\n    single logical-line.  This fixes continuation lines being\n    incorrectly reported as too long.\n\n  - |\n    Indentation now allows emacs-formatted idents, where continuation\n    lines for long commands align to the first argument above (rather\n    than a strict modulo of 4).  e.g.\n\n    ::\n\n       longcommand arg1 arg2 arg3 \\\n                   arg4 arg5\n\n    will no longer trigger a bad indent warning.\n\n  - Use ``bash -n`` to detect unclosed heredocs, rather than construct\n    our own parsing.\n\n  - Correctly check for newlines at the end of all files; even if you\n    only specify one file to check.\n"
  },
  {
    "path": "releasenotes/notes/python-3-4e30b9f2b9e2dcb7.yaml",
    "content": "---\nfeatures:\n\n  - Python 3 is supported"
  },
  {
    "path": "releasenotes/notes/start-using-reno-eaaafddb3fbf2010.yaml",
    "content": "---\nother:\n  - started using reno\n"
  },
  {
    "path": "releasenotes/source/conf.py",
    "content": "# -*- coding: utf-8 -*-\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n# implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# Bashate Release Notes documentation build configuration file, created by\n# sphinx-quickstart on Tue Nov  3 17:40:50 2015.\n#\n# This file is execfile()d with the current directory set to its\n# containing dir.\n#\n# Note that not all possible configuration values are present in this\n# autogenerated file.\n#\n# All configuration values have a default; values that are commented out\n# serve to show the default.\n\n# If extensions (or modules to document with autodoc) are in another directory,\n# add these directories to sys.path here. If the directory is relative to the\n# documentation root, use os.path.abspath to make it absolute, like shown here.\n# sys.path.insert(0, os.path.abspath('.'))\n\n# -- General configuration ------------------------------------------------\n\n# If your documentation needs a minimal Sphinx version, state it here.\n# needs_sphinx = '1.0'\n\n# Add any Sphinx extension module names here, as strings. They can be\n# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom\n# ones.\nextensions = [\n    'openstackdocstheme',\n    'reno.sphinxext',\n]\n\n# Add any paths that contain templates here, relative to this directory.\ntemplates_path = ['_templates']\n\n# The suffix of source filenames.\nsource_suffix = '.rst'\n\n# The encoding of source files.\n# source_encoding = 'utf-8-sig'\n\n# The master toctree document.\nmaster_doc = 'index'\n\n# General information about the project.\nproject = 'Bashate Release Notes'\ncopyright = '2017, Bashate Developers'\n\n# Release notes are version independent\n# The full version, including alpha/beta/rc tags.\nrelease = ''\n# The short X.Y version.\nversion = ''\n\n# The language for content autogenerated by Sphinx. Refer to documentation\n# for a list of supported languages.\n# language = None\n\n# There are two options for replacing |today|: either, you set today to some\n# non-false value, then it is used:\n# today = ''\n# Else, today_fmt is used as the format for a strftime call.\n# today_fmt = '%B %d, %Y'\n\n# List of patterns, relative to source directory, that match files and\n# directories to ignore when looking for source files.\nexclude_patterns = []\n\n# The reST default role (used for this markup: `text`) to use for all\n# documents.\n# default_role = None\n\n# If true, '()' will be appended to :func: etc. cross-reference text.\n# add_function_parentheses = True\n\n# If true, the current module name will be prepended to all description\n# unit titles (such as .. function::).\n# add_module_names = True\n\n# If true, sectionauthor and moduleauthor directives will be shown in the\n# output. They are ignored by default.\n# show_authors = False\n\n# The name of the Pygments (syntax highlighting) style to use.\npygments_style = 'native'\n\n# A list of ignored prefixes for module index sorting.\n# modindex_common_prefix = []\n\n# If true, keep warnings as \"system message\" paragraphs in the built documents.\n# keep_warnings = False\n\n# openstackdocstheme options\nopenstackdocs_repo_name = 'openstack-dev/bashate'\nopenstackdocs_bug_project = 'bashate'\nopenstackdocs_bug_tag = ''\nopenstackdocs_auto_name = False\n\n# -- Options for HTML output ----------------------------------------------\n\n# The theme to use for HTML and HTML Help pages.  See the documentation for\n# a list of builtin themes.\nhtml_theme = 'openstackdocs'\n\n# Theme options are theme-specific and customize the look and feel of a theme\n# further.  For a list of options available for each theme, see the\n# documentation.\n# html_theme_options = {}\n\n# Add any paths that contain custom themes here, relative to this directory.\n# html_theme_path = []\n\n# The name for this set of Sphinx documents.  If None, it defaults to\n# \"<project> v<release> documentation\".\n# html_title = None\n\n# A shorter title for the navigation bar.  Default is the same as html_title.\n# html_short_title = None\n\n# The name of an image file (relative to this directory) to place at the top\n# of the sidebar.\n# html_logo = None\n\n# The name of an image file (within the static path) to use as favicon of the\n# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32\n# pixels large.\n# html_favicon = None\n\n# Add any paths that contain custom static files (such as style sheets) here,\n# relative to this directory. They are copied after the builtin static files,\n# so a file named \"default.css\" will overwrite the builtin \"default.css\".\n# html_static_path = ['_static']\n\n# Add any extra paths that contain custom files (such as robots.txt or\n# .htaccess) here, relative to this directory. These files are copied\n# directly to the root of the documentation.\n# html_extra_path = []\n\n# If true, SmartyPants will be used to convert quotes and dashes to\n# typographically correct entities.\n# html_use_smartypants = True\n\n# Custom sidebar templates, maps document names to template names.\n# html_sidebars = {}\n\n# Additional templates that should be rendered to pages, maps page names to\n# template names.\n# html_additional_pages = {}\n\n# If false, no module index is generated.\n# html_domain_indices = True\n\n# If false, no index is generated.\n# html_use_index = True\n\n# If true, the index is split into individual pages for each letter.\n# html_split_index = False\n\n# If true, links to the reST sources are added to the pages.\n# html_show_sourcelink = True\n\n# If true, \"Created using Sphinx\" is shown in the HTML footer. Default is True.\n# html_show_sphinx = True\n\n# If true, \"(C) Copyright ...\" is shown in the HTML footer. Default is True.\n# html_show_copyright = True\n\n# If true, an OpenSearch description file will be output, and all pages will\n# contain a <link> tag referring to it.  The value of this option must be the\n# base URL from which the finished HTML is served.\n# html_use_opensearch = ''\n\n# This is the file name suffix for HTML files (e.g. \".xhtml\").\n# html_file_suffix = None\n\n# Output file base name for HTML help builder.\nhtmlhelp_basename = 'BashateReleaseNotesdoc'\n\n\n# -- Options for LaTeX output ---------------------------------------------\n\nlatex_elements = {\n    # The paper size ('letterpaper' or 'a4paper').\n    # 'papersize': 'letterpaper',\n\n    # The font size ('10pt', '11pt' or '12pt').\n    # 'pointsize': '10pt',\n\n    # Additional stuff for the LaTeX preamble.\n    # 'preamble': '',\n}\n\n# Grouping the document tree into LaTeX files. List of tuples\n# (source start file, target name, title,\n#  author, documentclass [howto, manual, or own class]).\nlatex_documents = [\n    ('index', 'BashateReleaseNotes.tex',\n     'Bashate Release Notes Documentation',\n     'Bashate Developers', 'manual'),\n]\n\n# The name of an image file (relative to this directory) to place at the top of\n# the title page.\n# latex_logo = None\n\n# For \"manual\" documents, if this is true, then toplevel headings are parts,\n# not chapters.\n# latex_use_parts = False\n\n# If true, show page references after internal links.\n# latex_show_pagerefs = False\n\n# If true, show URL addresses after external links.\n# latex_show_urls = False\n\n# Documents to append as an appendix to all manuals.\n# latex_appendices = []\n\n# If false, no module index is generated.\n# latex_domain_indices = True\n\n\n# -- Options for manual page output ---------------------------------------\n\n# One entry per manual page. List of tuples\n# (source start file, name, description, authors, manual section).\nman_pages = [\n    ('index', 'bashatereleasenotes', 'Bashate Release Notes Documentation',\n     ['Bashate Developers'], 1)\n]\n\n# If true, show URL addresses after external links.\n# man_show_urls = False\n\n\n# -- Options for Texinfo output -------------------------------------------\n\n# Grouping the document tree into Texinfo files. List of tuples\n# (source start file, target name, title, author,\n#  dir menu entry, description, category)\ntexinfo_documents = [\n    ('index', 'BashateReleaseNotes', 'Bashate Release Notes Documentation',\n     'Bashate Developers', 'BashateReleaseNotes',\n     'Style Checker for Bash.',\n     'Miscellaneous'),\n]\n\n# Documents to append as an appendix to all manuals.\n# texinfo_appendices = []\n\n# If false, no module index is generated.\n# texinfo_domain_indices = True\n\n# How to display URL addresses: 'footnote', 'no', or 'inline'.\n# texinfo_show_urls = 'footnote'\n\n# If true, do not generate a @detailmenu in the \"Top\" node's menu.\n# texinfo_no_detailmenu = False\n\n# -- Options for Internationalization output ------------------------------\nlocale_dirs = ['locale/']\n"
  },
  {
    "path": "releasenotes/source/index.rst",
    "content": "=====================\nbashate Release Notes\n=====================\n\n.. release-notes::\n"
  },
  {
    "path": "requirements.txt",
    "content": "pbr!=2.1.0,>=2.0.0 # Apache-2.0\n"
  },
  {
    "path": "setup.cfg",
    "content": "[metadata]\nname = bashate\nsummary = A pep8 equivalent for bash scripts\ndescription_file =\n    README.rst\nauthor = OpenStack\nauthor_email = openstack-discuss@lists.openstack.org\nhome_page = https://docs.openstack.org/bashate/latest/\npython_requires = >=3.5\nclassifier =\n    Environment :: OpenStack\n    Intended Audience :: Information Technology\n    Intended Audience :: System Administrators\n    License :: OSI Approved :: Apache Software License\n    Operating System :: POSIX :: Linux\n    Programming Language :: Python\n    Programming Language :: Python :: Implementation :: CPython\n    Programming Language :: Python :: 3 :: Only\n    Programming Language :: Python :: 3\n    Programming Language :: Python :: 3.5\n    Programming Language :: Python :: 3.6\n    Programming Language :: Python :: 3.7\n    Programming Language :: Python :: 3.8\n    Programming Language :: Python :: 3.9\n    Programming Language :: Python :: 3.10\n    Programming Language :: Python :: 3.11\n\n[files]\npackages =\n    bashate\n\n[entry_points]\nconsole_scripts =\n    bashate = bashate.bashate:main\n"
  },
  {
    "path": "setup.py",
    "content": "# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n# implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport setuptools\n\nsetuptools.setup(\n    setup_requires=['pbr>=1.8'],\n    pbr=True)\n"
  },
  {
    "path": "test-requirements.txt",
    "content": "hacking>=4.1.0,<4.2.0;python_version<'3.8' # Apache-2.0\nhacking>=7.0.0,<7.1.0;python_version>='3.8' # Apache-2.0\n\ncoverage>=3.6\ndiscover\nfixtures>=1.3.1\npython-subunit>=0.0.18\ntesttools>=2.2.0\nstestr>=1.0.0 # Apache-2.0\n"
  },
  {
    "path": "tox.ini",
    "content": "[tox]\nminversion = 3.18.0\nenvlist = py36,py39,pep8\nskipsdist = True\nignore_basepython_conflict = True\n\n[testenv]\nbasepython = python3\nusedevelop = True\nsetenv =\n   VIRTUAL_ENV={envdir}\nallowlist_externals = *\ndeps = -r{toxinidir}/requirements.txt\n       -r{toxinidir}/test-requirements.txt\ncommands =\n   stestr run --slowest {posargs}\n\n[testenv:pep8]\ncommands = flake8\n\n[testenv:docs]\ndeps = -r{toxinidir}/doc/requirements.txt\ncommands = sphinx-build -a -W -E -b html doc/source doc/build/html\n\n[testenv:pdf-docs]\ndeps = {[testenv:docs]deps}\nallowlist_externals =\n   make\ncommands =\n   sphinx-build -W -b latex doc/source doc/build/pdf\n   make -C doc/build/pdf\n\n[testenv:venv]\ncommands = {posargs}\n\n[testenv:cover]\nsetenv =\n  PYTHON=coverage run --source bashate --parallel-mode\ncommands =\n  coverage erase\n  find . -type f -name \"*.pyc\" -delete\n  stestr --test-path ./bashate/tests run {posargs}\n  coverage combine\n  coverage html -d cover\n  coverage xml -o cover/coverage.xml\n  coverage report\n\n[testenv:releasenotes]\ndeps = {[testenv:docs]deps}\ncommands = sphinx-build -a -W -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html\n\n[flake8]\n# E123, E125 skipped as they are invalid PEP-8.\n\nshow-source = True\nignore = E123,E125,W504\nbuiltins = _\nexclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build\n\n# This environment can be used to quickly validate that all needed system\n# packages required to successfully execute test targets are installed\n[testenv:bindep]\n# Do not install any requirements. We want this to be fast and work even if\n# system dependencies are missing, since it's used to tell you what system\n# dependencies are missing! This also means that bindep must be installed\n# separately, outside of the requirements files.\ndeps = bindep\ncommands = bindep test\n"
  }
]