├── vim ├── files │ ├── pyflakes │ │ └── ftplugin │ │ │ └── python │ │ │ ├── pyflakes │ │ │ ├── pyflakes │ │ │ │ ├── scripts │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── pyflakes.py │ │ │ │ ├── test │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── harness.py │ │ │ │ │ ├── test_script.py │ │ │ │ │ ├── test_undefined_names.py │ │ │ │ │ ├── test_other.py │ │ │ │ │ └── test_imports.py │ │ │ │ ├── __init__.py │ │ │ │ └── messages.py │ │ │ ├── bin │ │ │ │ └── pyflakes │ │ │ ├── setup.py │ │ │ ├── LICENSE │ │ │ ├── NEWS.txt │ │ │ └── README.rst │ │ │ └── pyflakes.vim │ ├── salt │ │ ├── ftdetect │ │ │ ├── jinja.vim │ │ │ └── sls.vim │ │ ├── ftplugin │ │ │ ├── rst.vim │ │ │ └── sls.vim │ │ └── syntax │ │ │ ├── sls.vim │ │ │ └── jinja.vim │ ├── nerdtree │ │ ├── nerdtree_plugin │ │ │ ├── exec_menuitem.vim │ │ │ └── fs_menu.vim │ │ └── syntax │ │ │ └── nerdtree.vim │ └── vimrc ├── absent.sls ├── salt.sls ├── nerdtree.sls ├── pyflakes.sls ├── _mapdata │ ├── _mapdata.jinja │ └── init.sls ├── init.sls ├── editor.sls └── map.jinja ├── .rstcheck.cfg ├── test ├── salt │ └── pillar │ │ └── vim.sls └── integration │ ├── default │ ├── controls │ │ ├── package_spec.rb │ │ └── config_spec.rb │ ├── inspec.yml │ └── README.md │ └── share │ ├── inspec.yml │ ├── README.md │ └── libraries │ └── system.rb ├── commitlint.config.js ├── .github └── workflows │ └── commitlint.yml ├── FORMULA ├── bin ├── install-hooks └── kitchen ├── .salt-lint ├── .rubocop.yml ├── release-rules.js ├── Gemfile ├── pre-commit_semantic-release.sh ├── pillar.example ├── .yamllint ├── .gitignore ├── .pre-commit-config.yaml ├── docs ├── README.rst ├── AUTHORS.rst └── CHANGELOG.rst ├── CODEOWNERS ├── release.config.js ├── AUTHORS.md ├── .travis.yml ├── kitchen.yml ├── .gitlab-ci.yml ├── CHANGELOG.md └── LICENSE /vim/files/pyflakes/ftplugin/python/pyflakes/pyflakes/scripts/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/pyflakes/test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/pyflakes/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | __version__ = '0.4.0' 3 | -------------------------------------------------------------------------------- /vim/files/salt/ftdetect/jinja.vim: -------------------------------------------------------------------------------- 1 | autocmd BufNewFile,BufRead *.jinja2,*.j2,*.jinja set ft=jinja 2 | -------------------------------------------------------------------------------- /vim/files/salt/ftdetect/sls.vim: -------------------------------------------------------------------------------- 1 | if has("autocmd") 2 | au BufNewFile,BufRead *.sls set filetype=sls 3 | endif 4 | -------------------------------------------------------------------------------- /vim/absent.sls: -------------------------------------------------------------------------------- 1 | {% from "vim/map.jinja" import vim with context %} 2 | 3 | vim: 4 | pkg.removed: 5 | - name: {{ vim.pkg }} 6 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/bin/pyflakes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | from pyflakes.scripts.pyflakes import main 4 | main() 5 | -------------------------------------------------------------------------------- /.rstcheck.cfg: -------------------------------------------------------------------------------- 1 | [rstcheck] 2 | report=info 3 | ignore_language=rst 4 | ignore_messages=(Duplicate (ex|im)plicit target.*|Hyperlink target ".*" is not referenced\.$) 5 | -------------------------------------------------------------------------------- /test/salt/pillar/vim.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | vim: 5 | managed_vimrc: true 6 | config: 7 | syntax: 'on' 8 | settings: 9 | number: ~ 10 | -------------------------------------------------------------------------------- /vim/files/salt/ftplugin/rst.vim: -------------------------------------------------------------------------------- 1 | " Use four spaces for indentation 2 | setlocal expandtab 3 | setlocal softtabstop=4 4 | setlocal shiftwidth=4 5 | 6 | " Wrap at 80 lines 7 | setlocal textwidth=79 8 | -------------------------------------------------------------------------------- /vim/salt.sls: -------------------------------------------------------------------------------- 1 | {% from "vim/map.jinja" import vim with context %} 2 | 3 | include: 4 | - vim 5 | 6 | salt_vimfiles: 7 | file.recurse: 8 | - name: {{ vim.share_dir }} 9 | - source: salt://vim/files/salt 10 | -------------------------------------------------------------------------------- /vim/nerdtree.sls: -------------------------------------------------------------------------------- 1 | {% from "vim/map.jinja" import vim with context %} 2 | 3 | include: 4 | - vim 5 | 6 | nerdtree_vimfiles: 7 | file.recurse: 8 | - name: {{ vim.share_dir }} 9 | - source: salt://vim/files/nerdtree 10 | -------------------------------------------------------------------------------- /vim/pyflakes.sls: -------------------------------------------------------------------------------- 1 | {% from "vim/map.jinja" import vim with context %} 2 | 3 | include: 4 | - vim 5 | 6 | pyflakes_vimfiles: 7 | file.recurse: 8 | - name: {{ vim.share_dir }} 9 | - source: salt://vim/files/pyflakes 10 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | rules: { 4 | 'body-max-line-length': [2, 'always', 120], 5 | 'footer-max-line-length': [2, 'always', 120], 6 | 'header-max-length': [2, 'always', 72], 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /test/integration/default/controls/package_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | control 'Vim package' do 4 | title 'should be installed' 5 | 6 | package_name = 7 | case platform[:family] 8 | when 'redhat', 'fedora' 9 | 'vim-enhanced' 10 | else 11 | 'vim' 12 | end 13 | 14 | describe package(package_name) do 15 | it { should be_installed } 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /.github/workflows/commitlint.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | name: Commitlint 5 | 'on': [pull_request] 6 | 7 | jobs: 8 | lint: 9 | runs-on: ubuntu-latest 10 | env: 11 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 12 | steps: 13 | - uses: actions/checkout@v2 14 | with: 15 | fetch-depth: 0 16 | - uses: wagoid/commitlint-github-action@v1 17 | -------------------------------------------------------------------------------- /vim/_mapdata/_mapdata.jinja: -------------------------------------------------------------------------------- 1 | # yamllint disable rule:indentation rule:line-length 2 | # {{ grains.get("osfinger", grains.os) }} 3 | --- 4 | {#- use salt.slsutil.serialize to avoid encoding errors on some platforms #} 5 | {{ salt["slsutil.serialize"]( 6 | "yaml", 7 | map, 8 | default_flow_style=False, 9 | allow_unicode=True, 10 | ) 11 | | regex_replace("^\s+'$", "'", multiline=True) 12 | | trim 13 | }} 14 | -------------------------------------------------------------------------------- /FORMULA: -------------------------------------------------------------------------------- 1 | name: vim 2 | os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Suse, openSUSE, Gentoo, Funtoo, Arch, Manjaro, Alpine, FreeBSD, OpenBSD, Solaris, SmartOS, MacOS 3 | os_family: Debian, RedHat, Suse, Gentoo, Arch, Alpine, FreeBSD, OpenBSD, Solaris, MacOS 4 | version: 0.15.5 5 | release: 0 6 | minimum_version: 2017.7 7 | summary: Vim formula 8 | description: Formula to use to install and configure vim 9 | top_level_dir: vim 10 | -------------------------------------------------------------------------------- /test/integration/default/controls/config_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | control 'Vim configuration' do 4 | title 'should match desired lines' 5 | 6 | config_file = 7 | case os[:family] 8 | when 'debian' 9 | '/etc/vim/vimrc' 10 | else 11 | '/etc/vimrc' 12 | end 13 | 14 | describe file(config_file) do 15 | # Custom config from pillar 16 | its('content') { should include 'syntax on' } 17 | its('content') { should include 'set number' } 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /vim/init.sls: -------------------------------------------------------------------------------- 1 | {% from "vim/map.jinja" import vim with context %} 2 | 3 | vim: 4 | pkg.installed: 5 | - pkgs: {{ vim.pkg|sequence|yaml }} 6 | 7 | {% if salt['pillar.get']('vim:managed_vimrc', True) == True %} 8 | {{ vim.config_root }}/vimrc: 9 | file.managed: 10 | - source: salt://vim/files/vimrc 11 | - template: jinja 12 | - user: root 13 | - group: {{ vim.group }} 14 | - mode: 644 15 | - makedirs: True 16 | - require: 17 | - pkg: vim 18 | - defaults: 19 | config_root: {{ vim.config_root }} 20 | {% endif %} 21 | -------------------------------------------------------------------------------- /bin/install-hooks: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | set -o nounset # Treat unset variables as an error and immediately exit 3 | set -o errexit # If a command fails exit the whole script 4 | 5 | if [ "${DEBUG:-false}" = "true" ]; then 6 | set -x # Run the entire script in debug mode 7 | fi 8 | 9 | if ! command -v pre-commit >/dev/null 2>&1; then 10 | echo "pre-commit not found: please install or check your PATH" >&2 11 | echo "See https://pre-commit.com/#installation" >&2 12 | exit 1 13 | fi 14 | 15 | pre-commit install --install-hooks 16 | pre-commit install --hook-type commit-msg --install-hooks 17 | -------------------------------------------------------------------------------- /.salt-lint: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | exclude_paths: [] 5 | rules: {} 6 | skip_list: 7 | # Using `salt-lint` for linting other files as well, such as Jinja macros/templates 8 | - 205 # Use ".sls" as a Salt State file extension 9 | # Skipping `207` and `208` because `210` is sufficient, at least for the time-being 10 | # I.e. Allows 3-digit unquoted codes to still be used, such as `644` and `755` 11 | - 207 # File modes should always be encapsulated in quotation marks 12 | - 208 # File modes should always contain a leading zero 13 | tags: [] 14 | verbosity: 1 15 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | # General overrides used across formulas in the org 5 | Layout/LineLength: 6 | # Increase from default of `80` 7 | # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`) 8 | Max: 88 9 | Metrics/BlockLength: 10 | IgnoredMethods: 11 | - control 12 | - describe 13 | # Increase from default of `25` 14 | Max: 30 15 | Security/YAMLLoad: 16 | Exclude: 17 | - test/integration/**/_mapdata.rb 18 | 19 | # General settings across all cops in this formula 20 | AllCops: 21 | NewCops: enable 22 | 23 | # Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config` 24 | -------------------------------------------------------------------------------- /vim/editor.sls: -------------------------------------------------------------------------------- 1 | {% from "vim/map.jinja" import vim with context %} 2 | 3 | include: 4 | - vim 5 | 6 | {% if 'alternatives' in vim %} 7 | {% set alt = vim.alternatives %} 8 | {% if 'link' in alt and 'path' in alt and 'priority' in alt %} 9 | {% if salt['alternatives.show_current']('editor') != alt.path %} 10 | install_editor_alternative: 11 | alternatives.install: 12 | - name: editor 13 | - link: {{ alt.link }} 14 | - path: {{ alt.path }} 15 | - priority: {{ alt.priority }} 16 | 17 | ensure_editor_alternative: 18 | alternatives.auto: 19 | - name: editor 20 | - require: 21 | - alternatives: install_editor_alternative 22 | {% endif %} 23 | {% endif %} 24 | {% endif %} 25 | -------------------------------------------------------------------------------- /test/integration/share/inspec.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | name: share 5 | title: InSpec shared resources 6 | maintainer: SaltStack Formulas 7 | license: Apache-2.0 8 | summary: shared resources 9 | supports: 10 | - platform-name: debian 11 | - platform-name: ubuntu 12 | - platform-name: centos 13 | - platform-name: fedora 14 | - platform-name: opensuse 15 | - platform-name: suse 16 | - platform-name: freebsd 17 | - platform-name: openbsd 18 | - platform-name: amazon 19 | - platform-name: oracle 20 | - platform-name: arch 21 | - platform-name: gentoo 22 | - platform-name: almalinux 23 | - platform-name: rocky 24 | - platform-name: mac_os_x 25 | - platform: windows 26 | -------------------------------------------------------------------------------- /release-rules.js: -------------------------------------------------------------------------------- 1 | // No release is triggered for the types commented out below. 2 | // Commits using these types will be incorporated into the next release. 3 | // 4 | // NOTE: Any changes here must be reflected in `CONTRIBUTING.md`. 5 | module.exports = [ 6 | {breaking: true, release: 'major'}, 7 | // {type: 'build', release: 'patch'}, 8 | // {type: 'chore', release: 'patch'}, 9 | // {type: 'ci', release: 'patch'}, 10 | {type: 'docs', release: 'patch'}, 11 | {type: 'feat', release: 'minor'}, 12 | {type: 'fix', release: 'patch'}, 13 | {type: 'perf', release: 'patch'}, 14 | {type: 'refactor', release: 'patch'}, 15 | {type: 'revert', release: 'patch'}, 16 | {type: 'style', release: 'patch'}, 17 | {type: 'test', release: 'patch'}, 18 | ]; 19 | -------------------------------------------------------------------------------- /vim/_mapdata/init.sls: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=sls 3 | --- 4 | {#- Get the `tplroot` from `tpldir` #} 5 | {%- set tplroot = tpldir.split("/")[0] %} 6 | {%- from tplroot ~ "/map.jinja" import vim with context %} 7 | 8 | {%- set _mapdata = { 9 | "values": vim, 10 | } %} 11 | {%- do salt["log.debug"]("### MAP.JINJA DUMP ###\n" ~ _mapdata | yaml(False)) %} 12 | 13 | {%- set output_dir = "/temp" if grains.os_family == "Windows" else "/tmp" %} 14 | {%- set output_file = output_dir ~ "/salt_mapdata_dump.yaml" %} 15 | 16 | {{ tplroot }}-mapdata-dump: 17 | file.managed: 18 | - name: {{ output_file }} 19 | - source: salt://{{ tplroot }}/_mapdata/_mapdata.jinja 20 | - template: jinja 21 | - context: 22 | map: {{ _mapdata | yaml }} 23 | -------------------------------------------------------------------------------- /test/integration/default/inspec.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | name: default 5 | title: vim formula 6 | maintainer: SaltStack Formulas 7 | license: Apache-2.0 8 | summary: Verify that the vim formula is setup and configured correctly 9 | depends: 10 | - name: share 11 | path: test/integration/share 12 | supports: 13 | - platform-name: debian 14 | - platform-name: ubuntu 15 | - platform-name: centos 16 | - platform-name: fedora 17 | - platform-name: opensuse 18 | - platform-name: suse 19 | - platform-name: freebsd 20 | - platform-name: openbsd 21 | - platform-name: amazon 22 | - platform-name: oracle 23 | - platform-name: arch 24 | - platform-name: gentoo 25 | - platform-name: almalinux 26 | - platform-name: rocky 27 | - platform-name: mac_os_x 28 | - platform: windows 29 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/pyflakes/test/harness.py: -------------------------------------------------------------------------------- 1 | 2 | import textwrap 3 | import _ast 4 | 5 | from twisted.trial import unittest 6 | 7 | from pyflakes import checker 8 | 9 | 10 | class Test(unittest.TestCase): 11 | 12 | def flakes(self, input, *expectedOutputs, **kw): 13 | ast = compile(textwrap.dedent(input), "", "exec", 14 | _ast.PyCF_ONLY_AST) 15 | w = checker.Checker(ast, **kw) 16 | outputs = [type(o) for o in w.messages] 17 | expectedOutputs = list(expectedOutputs) 18 | outputs.sort() 19 | expectedOutputs.sort() 20 | self.assert_(outputs == expectedOutputs, '''\ 21 | for input: 22 | %s 23 | expected outputs: 24 | %s 25 | but got: 26 | %s''' % (input, repr(expectedOutputs), '\n'.join([str(o) for o in w.messages]))) 27 | return w 28 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source ENV.fetch('PROXY_RUBYGEMSORG', 'https://rubygems.org') 4 | 5 | # Install the `inspec` gem using `git` because versions after `4.22.22` 6 | # suppress diff output; this version fixes this for our uses. 7 | # rubocop:disable Layout/LineLength 8 | gem 'inspec', git: 'https://gitlab.com/saltstack-formulas/infrastructure/inspec', branch: 'ssf' 9 | # rubocop:enable Layout/LineLength 10 | 11 | # Install the `kitchen-docker` gem using `git` in order to gain a performance 12 | # improvement: avoid package installations which are already covered by the 13 | # `salt-image-builder` (i.e. the pre-salted images that we're using) 14 | # rubocop:disable Layout/LineLength 15 | gem 'kitchen-docker', git: 'https://gitlab.com/saltstack-formulas/infrastructure/kitchen-docker', branch: 'ssf' 16 | # rubocop:enable Layout/LineLength 17 | 18 | gem 'kitchen-inspec', '>= 2.5.0' 19 | gem 'kitchen-salt', '>= 0.7.2' 20 | -------------------------------------------------------------------------------- /bin/kitchen: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'kitchen' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require 'pathname' 12 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', 13 | Pathname.new(__FILE__).realpath) 14 | 15 | bundle_binstub = File.expand_path('bundle', __dir__) 16 | 17 | if File.file?(bundle_binstub) 18 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ 19 | load(bundle_binstub) 20 | else 21 | abort( 22 | 'Your `bin/bundle` was not generated by Bundler, ' \ 23 | 'so this binstub cannot run. Replace `bin/bundle` by running ' \ 24 | '`bundle binstubs bundler --force`, then run this command again.' 25 | ) 26 | end 27 | end 28 | 29 | require 'rubygems' 30 | require 'bundler/setup' 31 | 32 | load Gem.bin_path('test-kitchen', 'kitchen') 33 | -------------------------------------------------------------------------------- /pre-commit_semantic-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ############################################################################### 4 | # (A) Update `FORMULA` with `${nextRelease.version}` 5 | ############################################################################### 6 | sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA 7 | 8 | 9 | ############################################################################### 10 | # (B) Use `m2r2` to convert automatically produced `.md` docs to `.rst` 11 | ############################################################################### 12 | 13 | # Install `m2r2` 14 | pip3 install m2r2 15 | 16 | # Copy and then convert the `.md` docs 17 | cp ./*.md docs/ 18 | cd docs/ || exit 19 | m2r2 --overwrite ./*.md 20 | 21 | # Change excess `H1` headings to `H2` in converted `CHANGELOG.rst` 22 | sed -i -e '/^=.*$/s/=/-/g' CHANGELOG.rst 23 | sed -i -e '1,4s/-/=/g' CHANGELOG.rst 24 | 25 | # Use for debugging output, when required 26 | # cat AUTHORS.rst 27 | # cat CHANGELOG.rst 28 | 29 | # Return back to the main directory 30 | cd .. 31 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # (c) 2005-2009 Divmod, Inc. See LICENSE file for details 3 | 4 | from distutils.core import setup 5 | 6 | setup( 7 | name="pyflakes", 8 | license="MIT", 9 | version="0.4.0", 10 | description="passive checker of Python programs", 11 | author="Phil Frost", 12 | maintainer="Moe Aboulkheir", 13 | maintainer_email="moe@divmod.com", 14 | url="http://www.divmod.org/trac/wiki/DivmodPyflakes", 15 | packages=["pyflakes", "pyflakes.scripts", "pyflakes.test"], 16 | scripts=["bin/pyflakes"], 17 | long_description="""Pyflakes is program to analyze Python programs and detect various errors. It 18 | works by parsing the source file, not importing it, so it is safe to use on 19 | modules with side effects. It's also much faster.""", 20 | classifiers=[ 21 | "Development Status :: 6 - Mature", 22 | "Environment :: Console", 23 | "Intended Audience :: Developers", 24 | "License :: OSI Approved :: MIT License", 25 | "Programming Language :: Python", 26 | "Topic :: Software Development", 27 | "Topic :: Utilities", 28 | ]) 29 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2005 Divmod, Inc., http://www.divmod.com/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vim/files/salt/syntax/sls.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Salt States template 3 | " Maintainer: Seth House 4 | " Last Change: 2012 June 20 5 | " 6 | if exists("b:current_syntax") 7 | finish 8 | endif 9 | 10 | if !exists("main_syntax") 11 | let main_syntax = 'yaml' 12 | endif 13 | 14 | let b:current_syntax = '' 15 | unlet b:current_syntax 16 | runtime! syntax/yaml.vim 17 | 18 | let b:current_syntax = '' 19 | unlet b:current_syntax 20 | syntax include @Yaml syntax/yaml.vim 21 | 22 | let b:current_syntax = '' 23 | unlet b:current_syntax 24 | syntax include @Jinja syntax/django.vim 25 | 26 | let g:NERDCustomDelimiters = { 'sls': { 'left': '#' }, } 27 | 28 | syn cluster djangoBlocks add=djangoTagBlock,djangoVarBlock,djangoComment,djangoComBlock 29 | syn region djangoTagBlock start="{%" end="%}" contains=djangoStatement,djangoFilter,djangoArgument,djangoTagError display containedin=ALLBUT,@djangoBlocks 30 | syn region djangoVarBlock start="{{" end="}}" contains=djangoFilter,djangoArgument,djangoVarError display containedin=ALLBUT,@djangoBlocks 31 | syn region djangoComBlock start="{#" end="#}" contains=djangoTodo containedin=ALLBUT,@djangoBlocks 32 | 33 | let b:current_syntax = "sls" 34 | -------------------------------------------------------------------------------- /pillar.example: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | vim: 5 | managed_vimrc: true 6 | allow_localrc: false 7 | config: 8 | syntax: 'on' 9 | colors: desert 10 | 11 | # Config options can be nested 12 | ia: 13 | marco: macro 14 | 15 | autocmd: 16 | FileType: 17 | sls: 'setlocal tabstop=2 softtabstop=2 shitfwidth=2' 18 | BufRead,BufNewFile: 19 | /etc/salt/*.conf: 'set filetype=sls' 20 | /srv/*.map: 'set filetype=sls' 21 | 22 | settings: 23 | et: ~ 24 | cin: ~ 25 | ru: ~ 26 | bs: indent,eol,start 27 | showcmd: ~ 28 | showmatch: ~ 29 | smartcase: ~ 30 | incsearch: ~ 31 | autowrite: ~ 32 | hidden: ~ 33 | mouse: a 34 | number: ~ 35 | backspace: 2 36 | noerrorbells: ~ 37 | novisualbell: ~ 38 | background: dark 39 | ai: ~ 40 | si: ~ 41 | cindent: ~ 42 | tabstop: 8 43 | softtabstop: 8 44 | shiftwidth: 8 45 | nowrap: ~ 46 | swapsync: '' 47 | 48 | mappings: 49 | : :tabp 50 | : :tabn 51 | : j 52 | : k 53 | : h 54 | : l 55 | 56 | lets: 57 | &colorcolumn: join(range(121,121),",") 58 | -------------------------------------------------------------------------------- /test/integration/default/README.md: -------------------------------------------------------------------------------- 1 | # InSpec Profile: `default` 2 | 3 | This shows the implementation of the `default` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md). 4 | 5 | ## Verify a profile 6 | 7 | InSpec ships with built-in features to verify a profile structure. 8 | 9 | ```bash 10 | $ inspec check default 11 | Summary 12 | ------- 13 | Location: default 14 | Profile: profile 15 | Controls: 4 16 | Timestamp: 2019-06-24T23:09:01+00:00 17 | Valid: true 18 | 19 | Errors 20 | ------ 21 | 22 | Warnings 23 | -------- 24 | ``` 25 | 26 | ## Execute a profile 27 | 28 | To run all **supported** controls on a local machine use `inspec exec /path/to/profile`. 29 | 30 | ```bash 31 | $ inspec exec default 32 | .. 33 | 34 | Finished in 0.0025 seconds (files took 0.12449 seconds to load) 35 | 8 examples, 0 failures 36 | ``` 37 | 38 | ## Execute a specific control from a profile 39 | 40 | To run one control from the profile use `inspec exec /path/to/profile --controls name`. 41 | 42 | ```bash 43 | $ inspec exec default --controls package 44 | . 45 | 46 | Finished in 0.0025 seconds (files took 0.12449 seconds to load) 47 | 1 examples, 0 failures 48 | ``` 49 | 50 | See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb). 51 | -------------------------------------------------------------------------------- /test/integration/share/README.md: -------------------------------------------------------------------------------- 1 | # InSpec Profile: `share` 2 | 3 | This shows the implementation of the `share` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md). 4 | 5 | Its goal is to share the libraries between all profiles. 6 | 7 | ## Libraries 8 | 9 | ### `system` 10 | 11 | The `system` library provides easy access to system dependent information: 12 | 13 | - `system.platform`: based on `inspec.platform`, modify to values that are more consistent from a SaltStack perspective 14 | - `system.platform[:family]` provide a family name for Arch and Gentoo 15 | - `system.platform[:name]` append `linux` to both `amazon` and `oracle`; ensure Windows platforms are resolved as simply `windows` 16 | - `system.platform[:release]` tweak Arch, Amazon Linux, Gentoo, openSUSE and Windows: 17 | - `Arch` is always `base-latest` 18 | - `Amazon Linux` release `2018` is resolved as `1` 19 | - `Gentoo` release is trimmed to its major version number and then the init system is appended (i.e. `sysv` or `sysd`) 20 | - `openSUSE` is resolved as `tumbleweed` if the `platform[:release]` is in date format 21 | - `Windows` uses the widely-used release number (e.g. `8.1` or `2019-server`) in place of the actual system release version 22 | - `system.platform[:finger]` is the concatenation of the name and the major release number (except for Ubuntu, which gives `ubuntu-20.04` for example) 23 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | # Extend the `default` configuration provided by `yamllint` 5 | extends: 'default' 6 | 7 | # Files to ignore completely 8 | # 1. All YAML files under directory `.bundle/`, introduced if gems are installed locally 9 | # 2. All YAML files under directory `.cache/`, introduced during the CI run 10 | # 3. All YAML files under directory `.git/` 11 | # 4. All YAML files under directory `node_modules/`, introduced during the CI run 12 | # 5. Any SLS files under directory `test/`, which are actually state files 13 | # 6. Any YAML files under directory `.kitchen/`, introduced during local testing 14 | # 7. `kitchen.vagrant.yml`, which contains Embedded Ruby (ERB) template syntax 15 | ignore: | 16 | .bundle/ 17 | .cache/ 18 | .git/ 19 | node_modules/ 20 | test/**/states/**/*.sls 21 | .kitchen/ 22 | kitchen.vagrant.yml 23 | 24 | yaml-files: 25 | # Default settings 26 | - '*.yaml' 27 | - '*.yml' 28 | - .salt-lint 29 | - .yamllint 30 | # SaltStack Formulas additional settings 31 | - '*.example' 32 | - test/**/*.sls 33 | 34 | rules: 35 | empty-values: 36 | forbid-in-block-mappings: true 37 | forbid-in-flow-mappings: true 38 | line-length: 39 | # Increase from default of `80` 40 | # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`) 41 | max: 88 42 | octal-values: 43 | forbid-implicit-octal: true 44 | forbid-explicit-octal: true 45 | -------------------------------------------------------------------------------- /vim/map.jinja: -------------------------------------------------------------------------------- 1 | {% set vim = salt['grains.filter_by']({ 2 | 'Arch': { 3 | 'pkg': 'vim', 4 | 'share_dir': '/usr/share/vim/vimfiles', 5 | 'group': 'root', 6 | 'config_root': '/etc', 7 | }, 8 | 'Debian': { 9 | 'alternatives': { 10 | 'link': '/usr/bin/editor', 11 | 'path': '/usr/bin/vim', 12 | 'priority': 100, 13 | }, 14 | 'pkg': 'vim', 15 | 'share_dir': '/usr/share/vim/vimfiles', 16 | 'group': 'root', 17 | 'config_root': '/etc/vim', 18 | }, 19 | 'OpenBSD': { 20 | 'pkg': 'vim--no_x11', 21 | 'share_dir': '/usr/local/share/vim/vimfiles', 22 | 'group': 'wheel', 23 | 'config_root': '/etc', 24 | }, 25 | 'RedHat': { 26 | 'pkg': 'vim-enhanced', 27 | 'share_dir': '/usr/share/vim/vimfiles', 28 | 'group': 'root', 29 | 'config_root': '/etc', 30 | }, 31 | 'Suse': { 32 | 'pkg': ['vim', 'vim-data'], 33 | 'share_dir': '/usr/share/vim/site', 34 | 'group': 'root', 35 | 'config_root': '/etc', 36 | }, 37 | 'FreeBSD': { 38 | 'pkg': 'vim', 39 | 'share_dir': '/usr/local/share/vim/vimfiles', 40 | 'group': 'wheel', 41 | 'config_root': '/etc', 42 | }, 43 | 'Gentoo': { 44 | 'pkg': 'app-editors/vim', 45 | 'share_dir': '/usr/share/vim/vimfiles', 46 | 'group': 'wheel', 47 | 'config_root': '/etc', 48 | }, 49 | }, merge=salt['pillar.get']('vim:lookup')) %} 50 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/NEWS.txt: -------------------------------------------------------------------------------- 1 | 0.4.0 (2009-11-25): 2 | - Fix reporting for certain SyntaxErrors which lack line number 3 | information. 4 | - Check for syntax errors more rigorously. 5 | - Support checking names used with the class decorator syntax in versions 6 | of Python which have it. 7 | - Detect local variables which are bound but never used. 8 | - Handle permission errors when trying to read source files. 9 | - Handle problems with the encoding of source files. 10 | - Support importing dotted names so as not to incorrectly report them as 11 | redefined unused names. 12 | - Support all forms of the with statement. 13 | - Consider static `__all__` definitions and avoid reporting unused names 14 | if the names are listed there. 15 | - Fix incorrect checking of class names with respect to the names of their 16 | bases in the class statement. 17 | - Support the `__path__` global in `__init__.py`. 18 | 19 | 0.3.0 (2009-01-30): 20 | - Display more informative SyntaxError messages. 21 | - Don't hang flymake with unmatched triple quotes (only report a single 22 | line of source for a multiline syntax error). 23 | - Recognize __builtins__ as a defined name. 24 | - Improve pyflakes support for python versions 2.3-2.5 25 | - Support for if-else expressions and with statements. 26 | - Warn instead of error on non-existant file paths. 27 | - Check for __future__ imports after other statements. 28 | - Add reporting for some types of import shadowing. 29 | - Improve reporting of unbound locals 30 | -------------------------------------------------------------------------------- /vim/files/salt/ftplugin/sls.vim: -------------------------------------------------------------------------------- 1 | " Use two-spaces for indentation 2 | setlocal expandtab 3 | setlocal softtabstop=2 4 | setlocal shiftwidth=2 5 | " do not display right side colorcolumn 6 | if version >= 703 7 | setlocal colorcolumn= 8 | endif 9 | 10 | setlocal wrap 11 | 12 | setlocal formatoptions=crl 13 | " r -> don't add comment leader after an Enter 14 | " c -> wrap long comments, including # 15 | " l -> do not wrap long lines 16 | 17 | " indentation 18 | setlocal autoindent 19 | 20 | " This function is from https://gist.github.com/871107 21 | " Author: Ian Young 22 | " 23 | function! GetYamlIndent() 24 | let lnum = v:lnum - 1 25 | if lnum == 0 26 | return 0 27 | endif 28 | let line = substitute(getline(lnum),'\s\+$','','') 29 | let indent = indent(lnum) 30 | let increase = indent + &sw 31 | if line =~ ':$' 32 | return increase 33 | else 34 | return indent 35 | endif 36 | endfunction 37 | 38 | setlocal indentexpr=GetYamlIndent() 39 | 40 | " folding 41 | setlocal foldmethod=indent 42 | setlocal foldlevel=6 " by default do not fold 43 | " fold/unfold using space 44 | nnoremap @=(foldlevel('.')?'za':"\") 45 | 46 | 47 | " Visual warning about UTF8 characters in SLS file. 48 | " salt does not like them much, so they should be red 49 | augroup utfsls 50 | autocmd! 51 | highlight UTFsls ctermbg=red guibg=red 52 | match UTFsls /[\x7F-\xFF]/ 53 | autocmd BufWinEnter * match UTFsls /[\x7F-\xFF]/ 54 | autocmd InsertEnter * match UTFsls /[\x7F-\xFF]/ 55 | autocmd InsertLeave * match UTFsls /[\x7F-\xFF]/ 56 | autocmd BufWinLeave * call clearmatches() 57 | augroup END 58 | 59 | 60 | 61 | " easier indenting of code blocks 62 | vnoremap < >gv " better indentation 64 | 65 | -------------------------------------------------------------------------------- /vim/files/nerdtree/nerdtree_plugin/exec_menuitem.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================ 2 | " File: exec_menuitem.vim 3 | " Description: plugin for NERD Tree that provides an execute file menu item 4 | " Maintainer: Martin Grenfell 5 | " Last Change: 22 July, 2009 6 | " License: This program is free software. It comes without any warranty, 7 | " to the extent permitted by applicable law. You can redistribute 8 | " it and/or modify it under the terms of the Do What The Fuck You 9 | " Want To Public License, Version 2, as published by Sam Hocevar. 10 | " See http://sam.zoy.org/wtfpl/COPYING for more details. 11 | " 12 | " ============================================================================ 13 | if exists("g:loaded_nerdtree_exec_menuitem") 14 | finish 15 | endif 16 | let g:loaded_nerdtree_exec_menuitem = 1 17 | 18 | call NERDTreeAddMenuItem({ 19 | \ 'text': '(!)Execute file', 20 | \ 'shortcut': '!', 21 | \ 'callback': 'NERDTreeExecFile', 22 | \ 'isActiveCallback': 'NERDTreeExecFileActive' }) 23 | 24 | function! NERDTreeExecFileActive() 25 | let node = g:NERDTreeFileNode.GetSelected() 26 | return !node.path.isDirectory && node.path.isExecutable 27 | endfunction 28 | 29 | function! NERDTreeExecFile() 30 | let treenode = g:NERDTreeFileNode.GetSelected() 31 | echo "==========================================================\n" 32 | echo "Complete the command to execute (add arguments etc):\n" 33 | let cmd = treenode.path.str({'escape': 1}) 34 | let cmd = input(':!', cmd . ' ') 35 | 36 | if cmd != '' 37 | exec ':!' . cmd 38 | else 39 | echo "Aborted" 40 | endif 41 | endfunction 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a packager 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .kitchen 49 | .kitchen.local.yml 50 | kitchen.local.yml 51 | junit-*.xml 52 | 53 | # Translations 54 | *.mo 55 | *.pot 56 | 57 | # Django stuff: 58 | *.log 59 | local_settings.py 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | 71 | # PyBuilder 72 | target/ 73 | 74 | # Jupyter Notebook 75 | .ipynb_checkpoints 76 | 77 | # pyenv 78 | .python-version 79 | 80 | # celery beat schedule file 81 | celerybeat-schedule 82 | 83 | # SageMath parsed files 84 | *.sage.py 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv 91 | venv/ 92 | ENV/ 93 | 94 | # visual studio 95 | .vs/ 96 | 97 | # Spyder project settings 98 | .spyderproject 99 | .spyproject 100 | 101 | # Rope project settings 102 | .ropeproject 103 | 104 | # mkdocs documentation 105 | /site 106 | 107 | # mypy 108 | .mypy_cache/ 109 | 110 | # Bundler 111 | .bundle/ 112 | 113 | # copied `.md` files used for conversion to `.rst` using `m2r` 114 | docs/*.md 115 | 116 | # Vim 117 | *.sw? 118 | 119 | ## Collected when centralising formulas (check and sort) 120 | # `collectd-formula` 121 | .pytest_cache/ 122 | /.idea/ 123 | Dockerfile.*_* 124 | ignore/ 125 | tmp/ 126 | 127 | # `salt-formula` -- Vagrant Specific files 128 | .vagrant 129 | top.sls 130 | !test/salt/pillar/top.sls 131 | 132 | # `suricata-formula` -- Platform binaries 133 | *.rpm 134 | *.deb 135 | -------------------------------------------------------------------------------- /vim/files/vimrc: -------------------------------------------------------------------------------- 1 | {% set config = salt['pillar.get']('vim:config', {}) -%} 2 | {% set settings = salt['pillar.get']('vim:settings', {}) -%} 3 | {% set mappings = salt['pillar.get']('vim:mappings', {}) -%} 4 | {% set lets = salt['pillar.get']('vim:lets', {}) -%} 5 | {% set allow_localrc = salt['pillar.get']('vim:allow_localrc', {}) -%} 6 | 7 | {% macro set_config(config, prefix='') -%} 8 | {% for parameter in config | sort -%} 9 | {% set value = config.get(parameter) -%} 10 | {% if value is mapping -%} 11 | {{ set_config(value, prefix=prefix+parameter+' ') }} 12 | {%- elif value is sequence and value is not string -%} 13 | {% for item in value -%} 14 | {{ prefix }}{{ parameter }} {{ item }} 15 | {% endfor -%} 16 | {%- elif value is not none -%} 17 | {{ prefix }}{{ parameter }} {{ value }} 18 | {% endif -%} 19 | {% endfor -%} 20 | {% endmacro -%} 21 | 22 | {% macro set_setting(parameter, default=None) -%} 23 | {% set value = settings.get(parameter, default) -%} 24 | {% if value is not none -%} 25 | set {{ parameter }}={{ value }} 26 | {% else -%} 27 | set {{ parameter }} 28 | {% endif -%} 29 | {% endmacro -%} 30 | 31 | {% macro set_mapping(parameter, default=None) -%} 32 | {% set value = mappings.get(parameter, default) -%} 33 | {% if value is not none -%} 34 | map {{ parameter }} {{ value }} 35 | {% endif -%} 36 | {% endmacro -%} 37 | 38 | {% macro set_let(parameter, default=None) -%} 39 | {% set value = lets.get(parameter, default) -%} 40 | {% if value is not none -%} 41 | let {{ parameter }} = {{ value }} 42 | {% endif -%} 43 | {% endmacro -%} 44 | 45 | {%- if grains['os'] == 'Arch' -%} 46 | runtime! archlinux.vim 47 | {% endif -%} 48 | 49 | {%- if grains['os'] == 'Debian' -%} 50 | runtime! debian.vim 51 | {% endif -%} 52 | 53 | {%- if config -%} 54 | {{ set_config(config) }} 55 | {% endif -%} 56 | 57 | {%- if settings -%} 58 | {% for parameter in settings | sort -%} 59 | {{ set_setting(parameter) }} 60 | {%- endfor %} 61 | {% endif -%} 62 | 63 | {%- if mappings -%} 64 | {% for parameter in mappings | sort -%} 65 | {{ set_mapping(parameter) }} 66 | {%- endfor %} 67 | {% endif -%} 68 | 69 | {%- if lets -%} 70 | {% for parameter in lets | sort -%} 71 | {{ set_let(parameter) }} 72 | {%- endfor %} 73 | {% endif -%} 74 | 75 | {%- if allow_localrc == True %} 76 | if filereadable("{{ config_root }}/vimrc.local") 77 | source {{ config_root }}/vimrc.local 78 | endif 79 | {% endif -%} 80 | 81 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | # See https://pre-commit.com for more information 5 | # See https://pre-commit.com/hooks.html for more hooks 6 | ci: 7 | autofix_commit_msg: | 8 | ci(pre-commit.ci): apply auto fixes from pre-commit.com hooks 9 | 10 | For more information, see https://pre-commit.ci 11 | autofix_prs: true 12 | autoupdate_branch: '' 13 | autoupdate_commit_msg: | 14 | ci(pre-commit.ci): perform `pre-commit` autoupdate 15 | autoupdate_schedule: quarterly 16 | skip: [] 17 | submodules: false 18 | default_stages: [commit] 19 | repos: 20 | - repo: https://github.com/dafyddj/commitlint-pre-commit-hook 21 | rev: v2.3.0 22 | hooks: 23 | - id: commitlint 24 | name: Check commit message using commitlint 25 | description: Lint commit message against @commitlint/config-conventional rules 26 | stages: [commit-msg] 27 | additional_dependencies: ['@commitlint/config-conventional@8.3.4'] 28 | - id: commitlint-travis 29 | stages: [manual] 30 | additional_dependencies: ['@commitlint/config-conventional@8.3.4'] 31 | always_run: true 32 | - repo: https://github.com/rubocop-hq/rubocop 33 | rev: v1.30.1 34 | hooks: 35 | - id: rubocop 36 | name: Check Ruby files with rubocop 37 | args: [--debug] 38 | always_run: true 39 | pass_filenames: false 40 | - repo: https://github.com/shellcheck-py/shellcheck-py 41 | rev: v0.8.0.4 42 | hooks: 43 | - id: shellcheck 44 | name: Check shell scripts with shellcheck 45 | files: ^.*\.(sh|bash|ksh)$ 46 | types: [] 47 | - repo: https://github.com/adrienverge/yamllint 48 | rev: v1.26.3 49 | hooks: 50 | - id: yamllint 51 | name: Check YAML syntax with yamllint 52 | args: [--strict, '.'] 53 | always_run: true 54 | pass_filenames: false 55 | - repo: https://github.com/warpnet/salt-lint 56 | rev: v0.8.0 57 | hooks: 58 | - id: salt-lint 59 | name: Check Salt files using salt-lint 60 | files: ^.*\.(sls|jinja|j2|tmpl|tst)$ 61 | - repo: https://github.com/myint/rstcheck 62 | rev: 3f929574 63 | hooks: 64 | - id: rstcheck 65 | name: Check reST files using rstcheck 66 | exclude: 'docs/CHANGELOG.rst' 67 | - repo: https://github.com/saltstack-formulas/mirrors-rst-lint 68 | rev: v1.3.2 69 | hooks: 70 | - id: rst-lint 71 | name: Check reST files using rst-lint 72 | exclude: | 73 | (?x)^( 74 | docs/CHANGELOG.rst| 75 | docs/TOFS_pattern.rst| 76 | )$ 77 | additional_dependencies: [pygments==2.9.0] 78 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/README.rst: -------------------------------------------------------------------------------- 1 | pyflakes-vim 2 | ============ 3 | 4 | A Vim plugin for checking Python code on the fly. 5 | 6 | PyFlakes catches common Python errors like mistyping a variable name or 7 | accessing a local before it is bound, and also gives warnings for things like 8 | unused imports. 9 | 10 | pyflakes-vim uses the output from PyFlakes to highlight errors in your code. 11 | To locate errors quickly, use quickfix_ commands like :cc. 12 | 13 | Make sure to check vim.org_ for the latest updates. 14 | 15 | .. _pyflakes.vim: http://www.vim.org/scripts/script.php?script_id=2441 16 | .. _vim.org: http://www.vim.org/scripts/script.php?script_id=2441 17 | .. _quickfix: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix 18 | 19 | Quick Installation 20 | ------------------ 21 | 22 | 1. Make sure your ``.vimrc`` has:: 23 | 24 | filetype on " enables filetype detection 25 | filetype plugin on " enables filetype specific plugins 26 | 27 | 2. Download the latest release_. 28 | 29 | 3. If you're using pathogen_, unzip the contents of ``pyflakes-vim.zip`` into 30 | its own bundle directory, i.e. into ``~/.vim/bundle/pyflakes-vim/``. 31 | 32 | Otherwise unzip ``pyflakes.vim`` and the ``pyflakes`` directory into 33 | ``~/.vim/ftplugin/python`` (or somewhere similar on your 34 | `runtime path`_ that will be sourced for Python files). 35 | 36 | .. _release: http://www.vim.org/scripts/script.php?script_id=2441 37 | .. _pathogen: http://www.vim.org/scripts/script.php?script_id=2332 38 | .. _runtime path: http://vimdoc.sourceforge.net/htmldoc/options.html#'runtimepath' 39 | 40 | Running from source 41 | ------------------- 42 | 43 | If you're running pyflakes-vim "from source," you'll need the PyFlakes library 44 | on your PYTHONPATH somewhere. (It is included in the vim.org zipfile.) I recommend 45 | getting my PyFlakes_ fork, which retains column number information, giving more 46 | specific error locations. 47 | 48 | .. _vim.org: http://www.vim.org/scripts/script.php?script_id=2441 49 | .. _PyFlakes: http://github.com/kevinw/pyflakes 50 | 51 | Hacking 52 | ------- 53 | 54 | :: 55 | 56 | git clone git://github.com/kevinw/pyflakes-vim.git 57 | cd pyflakes-vim 58 | git clone git://github.com/kevinw/pyflakes.git 59 | 60 | Options 61 | ------- 62 | 63 | Set this option to you vimrc file to disable quickfix support:: 64 | 65 | let g:pyflakes_use_quickfix = 0 66 | 67 | The value is set to 1 by default. 68 | 69 | TODO 70 | ---- 71 | * signs_ support (show warning and error icons to left of the buffer area) 72 | * configuration variables 73 | * parse or intercept useful output from the warnings module 74 | 75 | .. _signs: http://www.vim.org/htmldoc/sign.html 76 | 77 | Changelog 78 | --------- 79 | 80 | Please see http://www.vim.org/scripts/script.php?script_id=2441 for a history of 81 | all changes. 82 | 83 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/pyflakes/scripts/pyflakes.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Implementation of the command-line I{pyflakes} tool. 4 | """ 5 | 6 | import sys 7 | import os 8 | import _ast 9 | 10 | checker = __import__('pyflakes.checker').checker 11 | 12 | def check(codeString, filename): 13 | """ 14 | Check the Python source given by C{codeString} for flakes. 15 | 16 | @param codeString: The Python source to check. 17 | @type codeString: C{str} 18 | 19 | @param filename: The name of the file the source came from, used to report 20 | errors. 21 | @type filename: C{str} 22 | 23 | @return: The number of warnings emitted. 24 | @rtype: C{int} 25 | """ 26 | # First, compile into an AST and handle syntax errors. 27 | try: 28 | tree = compile(codeString, filename, "exec", _ast.PyCF_ONLY_AST) 29 | except SyntaxError, value: 30 | msg = value.args[0] 31 | 32 | (lineno, offset, text) = value.lineno, value.offset, value.text 33 | 34 | # If there's an encoding problem with the file, the text is None. 35 | if text is None: 36 | # Avoid using msg, since for the only known case, it contains a 37 | # bogus message that claims the encoding the file declared was 38 | # unknown. 39 | print >> sys.stderr, "%s: problem decoding source" % (filename, ) 40 | else: 41 | line = text.splitlines()[-1] 42 | 43 | if offset is not None: 44 | offset = offset - (len(text) - len(line)) 45 | 46 | print >> sys.stderr, '%s:%d: %s' % (filename, lineno, msg) 47 | print >> sys.stderr, line 48 | 49 | if offset is not None: 50 | print >> sys.stderr, " " * offset, "^" 51 | 52 | return 1 53 | else: 54 | # Okay, it's syntactically valid. Now check it. 55 | w = checker.Checker(tree, filename) 56 | w.messages.sort(lambda a, b: cmp(a.lineno, b.lineno)) 57 | for warning in w.messages: 58 | print warning 59 | return len(w.messages) 60 | 61 | 62 | def checkPath(filename): 63 | """ 64 | Check the given path, printing out any warnings detected. 65 | 66 | @return: the number of warnings printed 67 | """ 68 | try: 69 | return check(file(filename, 'U').read() + '\n', filename) 70 | except IOError, msg: 71 | print >> sys.stderr, "%s: %s" % (filename, msg.args[1]) 72 | return 1 73 | 74 | 75 | def main(): 76 | warnings = 0 77 | args = sys.argv[1:] 78 | if args: 79 | for arg in args: 80 | if os.path.isdir(arg): 81 | for dirpath, dirnames, filenames in os.walk(arg): 82 | for filename in filenames: 83 | if filename.endswith('.py'): 84 | warnings += checkPath(os.path.join(dirpath, filename)) 85 | else: 86 | warnings += checkPath(arg) 87 | else: 88 | warnings += check(sys.stdin.read(), '') 89 | 90 | raise SystemExit(warnings > 0) 91 | -------------------------------------------------------------------------------- /docs/README.rst: -------------------------------------------------------------------------------- 1 | .. _readme: 2 | 3 | vim-formula 4 | =========== 5 | 6 | |img_travis| |img_sr| 7 | 8 | .. |img_travis| image:: https://travis-ci.com/saltstack-formulas/vim-formula.svg?branch=master 9 | :alt: Travis CI Build Status 10 | :scale: 100% 11 | :target: https://travis-ci.com/saltstack-formulas/vim-formula 12 | .. |img_sr| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg 13 | :alt: Semantic Release 14 | :scale: 100% 15 | :target: https://github.com/semantic-release/semantic-release 16 | 17 | Formula to set up and configure vim. 18 | 19 | .. contents:: **Table of Contents** 20 | 21 | General notes 22 | ------------- 23 | 24 | See the full `SaltStack Formulas installation and usage instructions 25 | `_. 26 | 27 | If you are interested in writing or contributing to formulas, please pay attention to the `Writing Formula Section 28 | `_. 29 | 30 | If you want to use this formula, please pay attention to the ``FORMULA`` file and/or ``git tag``, 31 | which contains the currently released version. This formula is versioned according to `Semantic Versioning `_. 32 | 33 | See `Formula Versioning Section `_ for more details. 34 | 35 | Contributing to this repo 36 | ------------------------- 37 | 38 | **Commit message formatting is significant!!** 39 | 40 | Please see `How to contribute `_ for more details. 41 | 42 | Available states 43 | ---------------- 44 | 45 | .. contents:: 46 | :local: 47 | 48 | ``vim`` 49 | ^^^^^^^ 50 | Installs and configures the vim package. 51 | 52 | ``vim.salt`` 53 | ^^^^^^^^^^^^ 54 | Add the global plugins for editing sls files 55 | 56 | ``vim.nerdtree`` 57 | ^^^^^^^^^^^^^^^^ 58 | Add nerdtree plugin globally for vim 59 | 60 | ``vim.pyflakes`` 61 | ^^^^^^^^^^^^^^^^ 62 | Add pyflakes detection globaly for salt (may require installing gvim on some platforms) 63 | 64 | ``vim.absent`` 65 | ^^^^^^^^^^^^^^ 66 | Ensure vim is purged. 67 | 68 | Testing 69 | ------- 70 | 71 | Linux testing is done with ``kitchen-salt``. 72 | 73 | Requirements 74 | ^^^^^^^^^^^^ 75 | 76 | * Ruby 77 | * Docker 78 | 79 | .. code-block:: bash 80 | 81 | $ gem install bundler 82 | $ bundle install 83 | $ bin/kitchen test [platform] 84 | 85 | Where ``[platform]`` is the platform name defined in ``kitchen.yml``, 86 | e.g. ``debian-9-2019-2-py3``. 87 | 88 | ``bin/kitchen converge`` 89 | ^^^^^^^^^^^^^^^^^^^^^^^^ 90 | 91 | Creates the docker instance and runs the ``vim`` main state, ready for testing. 92 | 93 | ``bin/kitchen verify`` 94 | ^^^^^^^^^^^^^^^^^^^^^^ 95 | 96 | Runs the ``inspec`` tests on the actual instance. 97 | 98 | ``bin/kitchen destroy`` 99 | ^^^^^^^^^^^^^^^^^^^^^^^ 100 | 101 | Removes the docker instance. 102 | 103 | ``bin/kitchen test`` 104 | ^^^^^^^^^^^^^^^^^^^^ 105 | 106 | Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``. 107 | 108 | ``bin/kitchen login`` 109 | ^^^^^^^^^^^^^^^^^^^^^ 110 | 111 | Gives you SSH access to the instance for manual testing. 112 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/pyflakes/messages.py: -------------------------------------------------------------------------------- 1 | # (c) 2005 Divmod, Inc. See LICENSE file for details 2 | 3 | class Message(object): 4 | message = '' 5 | message_args = () 6 | def __init__(self, filename, loc, use_column=True): 7 | self.filename = filename 8 | self.lineno = loc.lineno 9 | self.col = getattr(loc, 'col_offset', None) if use_column else None 10 | 11 | def __str__(self): 12 | return '%s:%s: %s' % (self.filename, self.lineno, self.message % self.message_args) 13 | 14 | 15 | class UnusedImport(Message): 16 | message = '%r imported but unused' 17 | def __init__(self, filename, loc, name): 18 | Message.__init__(self, filename, loc, use_column=False) 19 | self.message_args = (name,) 20 | 21 | 22 | class RedefinedWhileUnused(Message): 23 | message = 'redefinition of unused %r from line %r' 24 | def __init__(self, filename, loc, name, orig_loc): 25 | Message.__init__(self, filename, loc) 26 | self.message_args = (name, orig_loc.lineno) 27 | 28 | 29 | class ImportShadowedByLoopVar(Message): 30 | message = 'import %r from line %r shadowed by loop variable' 31 | def __init__(self, filename, loc, name, orig_loc): 32 | Message.__init__(self, filename, loc) 33 | self.message_args = (name, orig_loc.lineno) 34 | 35 | 36 | class ImportStarUsed(Message): 37 | message = "'from %s import *' used; unable to detect undefined names" 38 | def __init__(self, filename, loc, modname): 39 | Message.__init__(self, filename, loc) 40 | self.message_args = (modname,) 41 | 42 | 43 | class UndefinedName(Message): 44 | message = 'undefined name %r' 45 | def __init__(self, filename, loc, name): 46 | Message.__init__(self, filename, loc) 47 | self.message_args = (name,) 48 | 49 | 50 | 51 | class UndefinedExport(Message): 52 | message = 'undefined name %r in __all__' 53 | def __init__(self, filename, loc, name): 54 | Message.__init__(self, filename, loc) 55 | self.message_args = (name,) 56 | 57 | 58 | 59 | class UndefinedLocal(Message): 60 | message = "local variable %r (defined in enclosing scope on line %r) referenced before assignment" 61 | def __init__(self, filename, loc, name, orig_loc): 62 | Message.__init__(self, filename, loc) 63 | self.message_args = (name, orig_loc.lineno) 64 | 65 | 66 | class DuplicateArgument(Message): 67 | message = 'duplicate argument %r in function definition' 68 | def __init__(self, filename, loc, name): 69 | Message.__init__(self, filename, loc) 70 | self.message_args = (name,) 71 | 72 | 73 | class RedefinedFunction(Message): 74 | message = 'redefinition of function %r from line %r' 75 | def __init__(self, filename, loc, name, orig_loc): 76 | Message.__init__(self, filename, loc) 77 | self.message_args = (name, orig_loc.lineno) 78 | 79 | 80 | class LateFutureImport(Message): 81 | message = 'future import(s) %r after other statements' 82 | def __init__(self, filename, loc, names): 83 | Message.__init__(self, filename, loc) 84 | self.message_args = (names,) 85 | 86 | 87 | class UnusedVariable(Message): 88 | """ 89 | Indicates that a variable has been explicity assigned to but not actually 90 | used. 91 | """ 92 | 93 | message = 'local variable %r is assigned to but never used' 94 | def __init__(self, filename, loc, names): 95 | Message.__init__(self, filename, loc) 96 | self.message_args = (names,) 97 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners 2 | 3 | # SECTION: Owner(s) for everything in the repo, unless a later match takes precedence 4 | # ************************************************************************** 5 | # *** NO GLOBAL OWNER(S) SPECIFIED *** 6 | # *** Ideally this will be defined for a healthy, well-maintained repo *** 7 | # ************************************************************************** 8 | # FILE PATTERN OWNER(S) 9 | * @NONE 10 | 11 | # SECTION: Owner(s) for specific directories 12 | # FILE PATTERN OWNER(S) 13 | 14 | # SECTION: Owner(s) for files/directories related to `semantic-release` 15 | # FILE PATTERN OWNER(S) 16 | /.github/workflows/ @saltstack-formulas/ssf 17 | /bin/install-hooks @saltstack-formulas/ssf 18 | /bin/kitchen @saltstack-formulas/ssf 19 | /docs/AUTHORS.rst @saltstack-formulas/ssf 20 | /docs/CHANGELOG.rst @saltstack-formulas/ssf 21 | /docs/TOFS_pattern.rst @saltstack-formulas/ssf 22 | /*/_mapdata/ @saltstack-formulas/ssf 23 | /*/libsaltcli.jinja @saltstack-formulas/ssf 24 | /*/libtofs.jinja @saltstack-formulas/ssf 25 | /test/integration/**/_mapdata.rb @saltstack-formulas/ssf 26 | /test/integration/**/libraries/system.rb @saltstack-formulas/ssf 27 | /test/integration/**/inspec.yml @saltstack-formulas/ssf 28 | /test/integration/**/README.md @saltstack-formulas/ssf 29 | /test/salt/pillar/top.sls @saltstack-formulas/ssf 30 | /.gitignore @saltstack-formulas/ssf 31 | /.cirrus.yml @saltstack-formulas/ssf 32 | /.gitlab-ci.yml @saltstack-formulas/ssf 33 | /.pre-commit-config.yaml @saltstack-formulas/ssf 34 | /.rstcheck.cfg @saltstack-formulas/ssf 35 | /.rubocop.yml @saltstack-formulas/ssf 36 | /.salt-lint @saltstack-formulas/ssf 37 | /.travis.yml @saltstack-formulas/ssf 38 | /.yamllint @saltstack-formulas/ssf 39 | /AUTHORS.md @saltstack-formulas/ssf 40 | /CHANGELOG.md @saltstack-formulas/ssf 41 | /CODEOWNERS @saltstack-formulas/ssf 42 | /commitlint.config.js @saltstack-formulas/ssf 43 | /FORMULA @saltstack-formulas/ssf 44 | /Gemfile @saltstack-formulas/ssf 45 | /Gemfile.lock @saltstack-formulas/ssf 46 | /kitchen.yml @saltstack-formulas/ssf 47 | /kitchen.vagrant.yml @saltstack-formulas/ssf 48 | /kitchen.windows.yml @saltstack-formulas/ssf 49 | /pre-commit_semantic-release.sh @saltstack-formulas/ssf 50 | /release-rules.js @saltstack-formulas/ssf 51 | /release.config.js @saltstack-formulas/ssf 52 | 53 | # SECTION: Owner(s) for specific files 54 | # FILE PATTERN OWNER(S) 55 | -------------------------------------------------------------------------------- /vim/files/nerdtree/syntax/nerdtree.vim: -------------------------------------------------------------------------------- 1 | let s:tree_up_dir_line = '.. (up a dir)' 2 | "NERDTreeFlags are syntax items that should be invisible, but give clues as to 3 | "how things should be highlighted 4 | syn match NERDTreeFlag #\~# 5 | syn match NERDTreeFlag #\[RO\]# 6 | 7 | "highlighting for the .. (up dir) line at the top of the tree 8 | execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#" 9 | 10 | "highlighting for the ~/+ symbols for the directory nodes 11 | syn match NERDTreeClosable #\~\<# 12 | syn match NERDTreeClosable #\~\.# 13 | syn match NERDTreeOpenable #+\<# 14 | syn match NERDTreeOpenable #+\.#he=e-1 15 | 16 | "highlighting for the tree structural parts 17 | syn match NERDTreePart #|# 18 | syn match NERDTreePart #`# 19 | syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart 20 | 21 | "quickhelp syntax elements 22 | syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1 23 | syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1 24 | syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag 25 | syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey 26 | syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey 27 | syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3 28 | syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand 29 | 30 | "highlighting for readonly files 31 | syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile 32 | 33 | "highlighting for sym links 34 | syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash 35 | 36 | "highlighing for directory nodes and file nodes 37 | syn match NERDTreeDirSlash #/# 38 | syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable 39 | syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark 40 | syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile 41 | syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile 42 | syn match NERDTreeCWD #^[# 49 | syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader 50 | syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader 51 | syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader 52 | 53 | if exists("g:NERDChristmasTree") && g:NERDChristmasTree 54 | hi def link NERDTreePart Special 55 | hi def link NERDTreePartFile Type 56 | hi def link NERDTreeFile Normal 57 | hi def link NERDTreeExecFile Title 58 | hi def link NERDTreeDirSlash Identifier 59 | hi def link NERDTreeClosable Type 60 | else 61 | hi def link NERDTreePart Normal 62 | hi def link NERDTreePartFile Normal 63 | hi def link NERDTreeFile Normal 64 | hi def link NERDTreeClosable Title 65 | endif 66 | 67 | hi def link NERDTreeBookmarksHeader statement 68 | hi def link NERDTreeBookmarksLeader ignore 69 | hi def link NERDTreeBookmarkName Identifier 70 | hi def link NERDTreeBookmark normal 71 | 72 | hi def link NERDTreeHelp String 73 | hi def link NERDTreeHelpKey Identifier 74 | hi def link NERDTreeHelpCommand Identifier 75 | hi def link NERDTreeHelpTitle Macro 76 | hi def link NERDTreeToggleOn Question 77 | hi def link NERDTreeToggleOff WarningMsg 78 | 79 | hi def link NERDTreeDir Directory 80 | hi def link NERDTreeUp Directory 81 | hi def link NERDTreeCWD Statement 82 | hi def link NERDTreeLink Macro 83 | hi def link NERDTreeOpenable Title 84 | hi def link NERDTreeFlag ignore 85 | hi def link NERDTreeRO WarningMsg 86 | hi def link NERDTreeBookmark Statement 87 | 88 | hi def link NERDTreeCurrentNode Search 89 | -------------------------------------------------------------------------------- /release.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | branch: 'master', 3 | repositoryUrl: 'https://github.com/saltstack-formulas/vim-formula', 4 | plugins: [ 5 | ['@semantic-release/commit-analyzer', { 6 | preset: 'angular', 7 | releaseRules: './release-rules.js', 8 | }], 9 | '@semantic-release/release-notes-generator', 10 | ['@semantic-release/changelog', { 11 | changelogFile: 'CHANGELOG.md', 12 | changelogTitle: '# Changelog', 13 | }], 14 | ['@semantic-release/exec', { 15 | prepareCmd: 'sh ./pre-commit_semantic-release.sh ${nextRelease.version}', 16 | }], 17 | ['@semantic-release/git', { 18 | assets: ['*.md', 'docs/*.rst', 'FORMULA'], 19 | }], 20 | '@semantic-release/github', 21 | ], 22 | generateNotes: { 23 | preset: 'angular', 24 | writerOpts: { 25 | // Required due to upstream bug preventing all types being displayed. 26 | // Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317 27 | // Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410 28 | transform: (commit, context) => { 29 | const issues = [] 30 | 31 | commit.notes.forEach(note => { 32 | note.title = `BREAKING CHANGES` 33 | }) 34 | 35 | // NOTE: Any changes here must be reflected in `CONTRIBUTING.md`. 36 | if (commit.type === `feat`) { 37 | commit.type = `Features` 38 | } else if (commit.type === `fix`) { 39 | commit.type = `Bug Fixes` 40 | } else if (commit.type === `perf`) { 41 | commit.type = `Performance Improvements` 42 | } else if (commit.type === `revert`) { 43 | commit.type = `Reverts` 44 | } else if (commit.type === `docs`) { 45 | commit.type = `Documentation` 46 | } else if (commit.type === `style`) { 47 | commit.type = `Styles` 48 | } else if (commit.type === `refactor`) { 49 | commit.type = `Code Refactoring` 50 | } else if (commit.type === `test`) { 51 | commit.type = `Tests` 52 | } else if (commit.type === `build`) { 53 | commit.type = `Build System` 54 | // } else if (commit.type === `chore`) { 55 | // commit.type = `Maintenance` 56 | } else if (commit.type === `ci`) { 57 | commit.type = `Continuous Integration` 58 | } else { 59 | return 60 | } 61 | 62 | if (commit.scope === `*`) { 63 | commit.scope = `` 64 | } 65 | 66 | if (typeof commit.hash === `string`) { 67 | commit.shortHash = commit.hash.substring(0, 7) 68 | } 69 | 70 | if (typeof commit.subject === `string`) { 71 | let url = context.repository 72 | ? `${context.host}/${context.owner}/${context.repository}` 73 | : context.repoUrl 74 | if (url) { 75 | url = `${url}/issues/` 76 | // Issue URLs. 77 | commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => { 78 | issues.push(issue) 79 | return `[#${issue}](${url}${issue})` 80 | }) 81 | } 82 | if (context.host) { 83 | // User URLs. 84 | commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => { 85 | if (username.includes('/')) { 86 | return `@${username}` 87 | } 88 | 89 | return `[@${username}](${context.host}/${username})` 90 | }) 91 | } 92 | } 93 | 94 | // remove references that already appear in the subject 95 | commit.references = commit.references.filter(reference => { 96 | if (issues.indexOf(reference.issue) === -1) { 97 | return true 98 | } 99 | 100 | return false 101 | }) 102 | 103 | return commit 104 | }, 105 | }, 106 | }, 107 | }; 108 | -------------------------------------------------------------------------------- /test/integration/share/libraries/system.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # system.rb -- InSpec resources for system values 4 | # Author: Daniel Dehennin 5 | # Copyright (C) 2020 Daniel Dehennin 6 | 7 | # rubocop:disable Metrics/ClassLength 8 | class SystemResource < Inspec.resource(1) 9 | name 'system' 10 | 11 | attr_reader :platform 12 | 13 | def initialize 14 | super 15 | @platform = build_platform 16 | end 17 | 18 | private 19 | 20 | def build_platform 21 | { 22 | family: build_platform_family, 23 | name: build_platform_name, 24 | release: build_platform_release, 25 | finger: build_platform_finger, 26 | codename: build_platform_codename 27 | } 28 | end 29 | 30 | def build_platform_family 31 | case inspec.platform[:name] 32 | when 'arch', 'gentoo' 33 | inspec.platform[:name] 34 | else 35 | inspec.platform[:family] 36 | end 37 | end 38 | 39 | def build_platform_name 40 | case inspec.platform[:name] 41 | when 'amazon', 'oracle', 'rocky' 42 | "#{inspec.platform[:name]}linux" 43 | when /^windows_/ 44 | inspec.platform[:family] 45 | else 46 | inspec.platform[:name] 47 | end 48 | end 49 | 50 | # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity 51 | def build_platform_release 52 | case inspec.platform[:name] 53 | when 'amazon' 54 | # `2018` relase is named `1` in `kitchen.yml` 55 | inspec.platform[:release].gsub(/2018.*/, '1') 56 | when 'arch' 57 | 'base-latest' 58 | when 'gentoo' 59 | "#{inspec.platform[:release].split('.')[0]}-#{derive_gentoo_init_system}" 60 | when 'mac_os_x' 61 | inspec.command('sw_vers -productVersion').stdout.to_s 62 | when 'opensuse' 63 | # rubocop:disable Style/NumericLiterals,Layout/LineLength 64 | inspec.platform[:release].to_i > 20210101 ? 'tumbleweed' : inspec.platform[:release] 65 | # rubocop:enable Style/NumericLiterals,Layout/LineLength 66 | when 'windows_8.1_pro' 67 | '8.1' 68 | when 'windows_server_2022_datacenter' 69 | '2022-server' 70 | when 'windows_server_2019_datacenter' 71 | '2019-server' 72 | when 'windows_server_2016_datacenter' 73 | '2016-server' 74 | else 75 | inspec.platform[:release] 76 | end 77 | end 78 | # rubocop:enable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity 79 | 80 | def derive_gentoo_init_system 81 | inspec.command('systemctl').exist? ? 'sysd' : 'sysv' 82 | end 83 | 84 | def build_platform_finger 85 | "#{build_platform_name}-#{build_finger_release}" 86 | end 87 | 88 | def build_finger_release 89 | case inspec.platform[:name] 90 | when 'ubuntu' 91 | build_platform_release.split('.').slice(0, 2).join('.') 92 | else 93 | build_platform_release.split('.')[0] 94 | end 95 | end 96 | 97 | # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity 98 | def build_platform_codename 99 | case build_platform_finger 100 | when 'ubuntu-22.04' 101 | 'jammy' 102 | when 'ubuntu-20.04' 103 | 'focal' 104 | when 'ubuntu-18.04' 105 | 'bionic' 106 | when 'debian-11' 107 | 'bullseye' 108 | when 'debian-10' 109 | 'buster' 110 | when 'debian-9' 111 | 'stretch' 112 | when 'almalinux-8' 113 | "AlmaLinux #{build_platform_release} (Arctic Sphynx)" 114 | when 'amazonlinux-2' 115 | 'Amazon Linux 2' 116 | when 'arch-base-latest' 117 | 'Arch Linux' 118 | when 'centos-7' 119 | 'CentOS Linux 7 (Core)' 120 | when 'centos-8' 121 | 'CentOS Stream 8' 122 | when 'opensuse-tumbleweed' 123 | 'openSUSE Tumbleweed' 124 | when 'opensuse-15' 125 | "openSUSE Leap #{build_platform_release}" 126 | when 'oraclelinux-8', 'oraclelinux-7' 127 | "Oracle Linux Server #{build_platform_release}" 128 | when 'gentoo-2-sysd', 'gentoo-2-sysv' 129 | 'Gentoo/Linux' 130 | when 'rockylinux-8' 131 | "Rocky Linux #{build_platform_release} (Green Obsidian)" 132 | else 133 | '' 134 | end 135 | end 136 | # rubocop:enable Metrics/MethodLength,Metrics/CyclomaticComplexity 137 | end 138 | # rubocop:enable Metrics/ClassLength 139 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Authors 2 | 3 | This list is sorted by the number of commits per contributor in _descending_ order. 4 | 5 | Avatar|Contributor|Contributions 6 | :-:|---|:-: 7 | @myii|[@myii](https://github.com/myii)|96 8 | @aboe76|[@aboe76](https://github.com/aboe76)|10 9 | @gravyboat|[@gravyboat](https://github.com/gravyboat)|10 10 | @nmadhok|[@nmadhok](https://github.com/nmadhok)|6 11 | @thatch45|[@thatch45](https://github.com/thatch45)|5 12 | @n-rodriguez|[@n-rodriguez](https://github.com/n-rodriguez)|4 13 | @Azulinho|[@Azulinho](https://github.com/Azulinho)|3 14 | @dafyddj|[@dafyddj](https://github.com/dafyddj)|3 15 | @BrandonIngalls|[@BrandonIngalls](https://github.com/BrandonIngalls)|2 16 | @UtahDave|[@UtahDave](https://github.com/UtahDave)|2 17 | @techhat|[@techhat](https://github.com/techhat)|2 18 | @stp-ip|[@stp-ip](https://github.com/stp-ip)|2 19 | @whiteinge|[@whiteinge](https://github.com/whiteinge)|2 20 | @tibold|[@tibold](https://github.com/tibold)|2 21 | @devster31|[@devster31](https://github.com/devster31)|2 22 | @alxwr|[@alxwr](https://github.com/alxwr)|1 23 | @alinefr|[@alinefr](https://github.com/alinefr)|1 24 | @SuperTux88|[@SuperTux88](https://github.com/SuperTux88)|1 25 | @alcarithemad|[@alcarithemad](https://github.com/alcarithemad)|1 26 | @baby-gnu|[@baby-gnu](https://github.com/baby-gnu)|1 27 | @evverss|[@evverss](https://github.com/evverss)|1 28 | @EvaSDK|[@EvaSDK](https://github.com/EvaSDK)|1 29 | @imran1008|[@imran1008](https://github.com/imran1008)|1 30 | @codekoala|[@codekoala](https://github.com/codekoala)|1 31 | @boileaum|[@boileaum](https://github.com/boileaum)|1 32 | @noelmcloughlin|[@noelmcloughlin](https://github.com/noelmcloughlin)|1 33 | @stasjok|[@stasjok](https://github.com/stasjok)|1 34 | @babilen|[@babilen](https://github.com/babilen)|1 35 | @lesar|[@lesar](https://github.com/lesar)|1 36 | @puneetk|[@puneetk](https://github.com/puneetk)|1 37 | 38 | --- 39 | 40 | Auto-generated by a [forked version](https://github.com/myii/maintainer) of [gaocegege/maintainer](https://github.com/gaocegege/maintainer) on 2021-10-27. 41 | -------------------------------------------------------------------------------- /vim/files/salt/syntax/jinja.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Jinja template 3 | " Maintainer: Armin Ronacher 4 | " Last Change: 2008 May 9 5 | " Version: 1.1 6 | " 7 | " Known Bugs: 8 | " because of odd limitations dicts and the modulo operator 9 | " appear wrong in the template. 10 | " 11 | " Changes: 12 | " 13 | " 2008 May 9: Added support for Jinja2 changes (new keyword rules) 14 | 15 | " .vimrc variable to disable html highlighting 16 | if !exists('g:jinja_syntax_html') 17 | let g:jinja_syntax_html=1 18 | endif 19 | 20 | " For version 5.x: Clear all syntax items 21 | " For version 6.x: Quit when a syntax file was already loaded 22 | if !exists("main_syntax") 23 | if version < 600 24 | syntax clear 25 | elseif exists("b:current_syntax") 26 | finish 27 | endif 28 | let main_syntax = 'jinja' 29 | endif 30 | 31 | " Pull in the HTML syntax. 32 | if g:jinja_syntax_html 33 | if version < 600 34 | so :p:h/html.vim 35 | else 36 | runtime! syntax/html.vim 37 | unlet b:current_syntax 38 | endif 39 | endif 40 | 41 | syntax case match 42 | 43 | " Jinja template built-in tags and parameters (without filter, macro, is and raw, they 44 | " have special threatment) 45 | syn keyword jinjaStatement containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained and if else in not or recursive as import 46 | 47 | syn keyword jinjaStatement containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained is filter skipwhite nextgroup=jinjaFilter 48 | syn keyword jinjaStatement containedin=jinjaTagBlock contained macro skipwhite nextgroup=jinjaFunction 49 | syn keyword jinjaStatement containedin=jinjaTagBlock contained block skipwhite nextgroup=jinjaBlockName 50 | 51 | " Variable Names 52 | syn match jinjaVariable containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[a-zA-Z_][a-zA-Z0-9_]*/ 53 | syn keyword jinjaSpecial containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained false true none False True None loop super caller varargs kwargs 54 | 55 | " Filters 56 | syn match jinjaOperator "|" containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained skipwhite nextgroup=jinjaFilter 57 | syn match jinjaFilter contained /[a-zA-Z_][a-zA-Z0-9_]*/ 58 | syn match jinjaFunction contained /[a-zA-Z_][a-zA-Z0-9_]*/ 59 | syn match jinjaBlockName contained /[a-zA-Z_][a-zA-Z0-9_]*/ 60 | 61 | " Jinja template constants 62 | syn region jinjaString containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained start=/"/ skip=/\(\\\)\@\)*\\"/ end=/"/ 63 | syn region jinjaString containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained start=/'/ skip=/\(\\\)\@\)*\\'/ end=/'/ 64 | syn match jinjaNumber containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[0-9]\+\(\.[0-9]\+\)\?/ 65 | 66 | " Operators 67 | syn match jinjaOperator containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[+\-*\/<>=!,:]/ 68 | syn match jinjaPunctuation containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /[()\[\]]/ 69 | syn match jinjaOperator containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained /\./ nextgroup=jinjaAttribute 70 | syn match jinjaAttribute contained /[a-zA-Z_][a-zA-Z0-9_]*/ 71 | 72 | " Jinja template tag and variable blocks 73 | syn region jinjaNested matchgroup=jinjaOperator start="(" end=")" transparent display containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained 74 | syn region jinjaNested matchgroup=jinjaOperator start="\[" end="\]" transparent display containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained 75 | syn region jinjaNested matchgroup=jinjaOperator start="{" end="}" transparent display containedin=jinjaVarBlock,jinjaTagBlock,jinjaNested contained 76 | syn region jinjaTagBlock matchgroup=jinjaTagDelim start=/{%-\?/ end=/-\?%}/ containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaRaw,jinjaString,jinjaNested,jinjaComment 77 | 78 | syn region jinjaVarBlock matchgroup=jinjaVarDelim start=/{{-\?/ end=/-\?}}/ containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaRaw,jinjaString,jinjaNested,jinjaComment 79 | 80 | " Jinja template 'raw' tag 81 | syn region jinjaRaw matchgroup=jinjaRawDelim start="{%\s*raw\s*%}" end="{%\s*endraw\s*%}" containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaString,jinjaComment 82 | 83 | " Jinja comments 84 | syn region jinjaComment matchgroup=jinjaCommentDelim start="{#" end="#}" containedin=ALLBUT,jinjaTagBlock,jinjaVarBlock,jinjaString 85 | 86 | " Block start keywords. A bit tricker. We only highlight at the start of a 87 | " tag block and only if the name is not followed by a comma or equals sign 88 | " which usually means that we have to deal with an assignment. 89 | syn match jinjaStatement containedin=jinjaTagBlock contained /\({%-\?\s*\)\@<=\<[a-zA-Z_][a-zA-Z0-9_]*\>\(\s*[,=]\)\@!/ 90 | 91 | " and context modifiers 92 | syn match jinjaStatement containedin=jinjaTagBlock contained /\/ 93 | 94 | 95 | " Define the default highlighting. 96 | " For version 5.7 and earlier: only when not done already 97 | " For version 5.8 and later: only when an item doesn't have highlighting yet 98 | if version >= 508 || !exists("did_jinja_syn_inits") 99 | if version < 508 100 | let did_jinja_syn_inits = 1 101 | command -nargs=+ HiLink hi link 102 | else 103 | command -nargs=+ HiLink hi def link 104 | endif 105 | 106 | HiLink jinjaPunctuation jinjaOperator 107 | HiLink jinjaAttribute jinjaVariable 108 | HiLink jinjaFunction jinjaFilter 109 | 110 | HiLink jinjaTagDelim jinjaTagBlock 111 | HiLink jinjaVarDelim jinjaVarBlock 112 | HiLink jinjaCommentDelim jinjaComment 113 | HiLink jinjaRawDelim jinja 114 | 115 | HiLink jinjaSpecial Special 116 | HiLink jinjaOperator Normal 117 | HiLink jinjaRaw Normal 118 | HiLink jinjaTagBlock PreProc 119 | HiLink jinjaVarBlock PreProc 120 | HiLink jinjaStatement Statement 121 | HiLink jinjaFilter Function 122 | HiLink jinjaBlockName Function 123 | HiLink jinjaVariable Identifier 124 | HiLink jinjaString Constant 125 | HiLink jinjaNumber Constant 126 | HiLink jinjaComment Comment 127 | 128 | delcommand HiLink 129 | endif 130 | 131 | let b:current_syntax = "jinja" 132 | 133 | if main_syntax == 'jinja' 134 | unlet main_syntax 135 | endif 136 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/pyflakes/test/test_script.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Tests for L{pyflakes.scripts.pyflakes}. 4 | """ 5 | 6 | import sys 7 | from StringIO import StringIO 8 | 9 | from twisted.python.filepath import FilePath 10 | from twisted.trial.unittest import TestCase 11 | 12 | from pyflakes.scripts.pyflakes import checkPath 13 | 14 | def withStderrTo(stderr, f): 15 | """ 16 | Call C{f} with C{sys.stderr} redirected to C{stderr}. 17 | """ 18 | (outer, sys.stderr) = (sys.stderr, stderr) 19 | try: 20 | return f() 21 | finally: 22 | sys.stderr = outer 23 | 24 | 25 | 26 | class CheckTests(TestCase): 27 | """ 28 | Tests for L{check} and L{checkPath} which check a file for flakes. 29 | """ 30 | def test_missingTrailingNewline(self): 31 | """ 32 | Source which doesn't end with a newline shouldn't cause any 33 | exception to be raised nor an error indicator to be returned by 34 | L{check}. 35 | """ 36 | fName = self.mktemp() 37 | FilePath(fName).setContent("def foo():\n\tpass\n\t") 38 | self.assertFalse(checkPath(fName)) 39 | 40 | 41 | def test_checkPathNonExisting(self): 42 | """ 43 | L{checkPath} handles non-existing files. 44 | """ 45 | err = StringIO() 46 | count = withStderrTo(err, lambda: checkPath('extremo')) 47 | self.assertEquals(err.getvalue(), 'extremo: No such file or directory\n') 48 | self.assertEquals(count, 1) 49 | 50 | 51 | def test_multilineSyntaxError(self): 52 | """ 53 | Source which includes a syntax error which results in the raised 54 | L{SyntaxError.text} containing multiple lines of source are reported 55 | with only the last line of that source. 56 | """ 57 | source = """\ 58 | def foo(): 59 | ''' 60 | 61 | def bar(): 62 | pass 63 | 64 | def baz(): 65 | '''quux''' 66 | """ 67 | 68 | # Sanity check - SyntaxError.text should be multiple lines, if it 69 | # isn't, something this test was unprepared for has happened. 70 | def evaluate(source): 71 | exec source 72 | exc = self.assertRaises(SyntaxError, evaluate, source) 73 | self.assertTrue(exc.text.count('\n') > 1) 74 | 75 | sourcePath = FilePath(self.mktemp()) 76 | sourcePath.setContent(source) 77 | err = StringIO() 78 | count = withStderrTo(err, lambda: checkPath(sourcePath.path)) 79 | self.assertEqual(count, 1) 80 | 81 | self.assertEqual( 82 | err.getvalue(), 83 | """\ 84 | %s:8: invalid syntax 85 | '''quux''' 86 | ^ 87 | """ % (sourcePath.path,)) 88 | 89 | 90 | def test_eofSyntaxError(self): 91 | """ 92 | The error reported for source files which end prematurely causing a 93 | syntax error reflects the cause for the syntax error. 94 | """ 95 | source = "def foo(" 96 | sourcePath = FilePath(self.mktemp()) 97 | sourcePath.setContent(source) 98 | err = StringIO() 99 | count = withStderrTo(err, lambda: checkPath(sourcePath.path)) 100 | self.assertEqual(count, 1) 101 | self.assertEqual( 102 | err.getvalue(), 103 | """\ 104 | %s:1: unexpected EOF while parsing 105 | def foo( 106 | ^ 107 | """ % (sourcePath.path,)) 108 | 109 | 110 | def test_nonDefaultFollowsDefaultSyntaxError(self): 111 | """ 112 | Source which has a non-default argument following a default argument 113 | should include the line number of the syntax error. However these 114 | exceptions do not include an offset. 115 | """ 116 | source = """\ 117 | def foo(bar=baz, bax): 118 | pass 119 | """ 120 | sourcePath = FilePath(self.mktemp()) 121 | sourcePath.setContent(source) 122 | err = StringIO() 123 | count = withStderrTo(err, lambda: checkPath(sourcePath.path)) 124 | self.assertEqual(count, 1) 125 | self.assertEqual( 126 | err.getvalue(), 127 | """\ 128 | %s:1: non-default argument follows default argument 129 | def foo(bar=baz, bax): 130 | """ % (sourcePath.path,)) 131 | 132 | 133 | def test_nonKeywordAfterKeywordSyntaxError(self): 134 | """ 135 | Source which has a non-keyword argument after a keyword argument should 136 | include the line number of the syntax error. However these exceptions 137 | do not include an offset. 138 | """ 139 | source = """\ 140 | foo(bar=baz, bax) 141 | """ 142 | sourcePath = FilePath(self.mktemp()) 143 | sourcePath.setContent(source) 144 | err = StringIO() 145 | count = withStderrTo(err, lambda: checkPath(sourcePath.path)) 146 | self.assertEqual(count, 1) 147 | self.assertEqual( 148 | err.getvalue(), 149 | """\ 150 | %s:1: non-keyword arg after keyword arg 151 | foo(bar=baz, bax) 152 | """ % (sourcePath.path,)) 153 | 154 | 155 | def test_permissionDenied(self): 156 | """ 157 | If the a source file is not readable, this is reported on standard 158 | error. 159 | """ 160 | sourcePath = FilePath(self.mktemp()) 161 | sourcePath.setContent('') 162 | sourcePath.chmod(0) 163 | err = StringIO() 164 | count = withStderrTo(err, lambda: checkPath(sourcePath.path)) 165 | self.assertEquals(count, 1) 166 | self.assertEquals( 167 | err.getvalue(), "%s: Permission denied\n" % (sourcePath.path,)) 168 | 169 | 170 | def test_misencodedFile(self): 171 | """ 172 | If a source file contains bytes which cannot be decoded, this is 173 | reported on stderr. 174 | """ 175 | source = u"""\ 176 | # coding: ascii 177 | x = "\N{SNOWMAN}" 178 | """.encode('utf-8') 179 | sourcePath = FilePath(self.mktemp()) 180 | sourcePath.setContent(source) 181 | err = StringIO() 182 | count = withStderrTo(err, lambda: checkPath(sourcePath.path)) 183 | self.assertEquals(count, 1) 184 | self.assertEquals( 185 | err.getvalue(), "%s: problem decoding source\n" % (sourcePath.path,)) 186 | -------------------------------------------------------------------------------- /docs/AUTHORS.rst: -------------------------------------------------------------------------------- 1 | .. role:: raw-html-m2r(raw) 2 | :format: html 3 | 4 | 5 | Authors 6 | ======= 7 | 8 | This list is sorted by the number of commits per contributor in *descending* order. 9 | 10 | .. list-table:: 11 | :header-rows: 1 12 | 13 | * - Avatar 14 | - Contributor 15 | - Contributions 16 | * - :raw-html-m2r:`@myii` 17 | - `@myii `_ 18 | - 96 19 | * - :raw-html-m2r:`@aboe76` 20 | - `@aboe76 `_ 21 | - 10 22 | * - :raw-html-m2r:`@gravyboat` 23 | - `@gravyboat `_ 24 | - 10 25 | * - :raw-html-m2r:`@nmadhok` 26 | - `@nmadhok `_ 27 | - 6 28 | * - :raw-html-m2r:`@thatch45` 29 | - `@thatch45 `_ 30 | - 5 31 | * - :raw-html-m2r:`@n-rodriguez` 32 | - `@n-rodriguez `_ 33 | - 4 34 | * - :raw-html-m2r:`@Azulinho` 35 | - `@Azulinho `_ 36 | - 3 37 | * - :raw-html-m2r:`@dafyddj` 38 | - `@dafyddj `_ 39 | - 3 40 | * - :raw-html-m2r:`@BrandonIngalls` 41 | - `@BrandonIngalls `_ 42 | - 2 43 | * - :raw-html-m2r:`@UtahDave` 44 | - `@UtahDave `_ 45 | - 2 46 | * - :raw-html-m2r:`@techhat` 47 | - `@techhat `_ 48 | - 2 49 | * - :raw-html-m2r:`@stp-ip` 50 | - `@stp-ip `_ 51 | - 2 52 | * - :raw-html-m2r:`@whiteinge` 53 | - `@whiteinge `_ 54 | - 2 55 | * - :raw-html-m2r:`@tibold` 56 | - `@tibold `_ 57 | - 2 58 | * - :raw-html-m2r:`@devster31` 59 | - `@devster31 `_ 60 | - 2 61 | * - :raw-html-m2r:`@alxwr` 62 | - `@alxwr `_ 63 | - 1 64 | * - :raw-html-m2r:`@alinefr` 65 | - `@alinefr `_ 66 | - 1 67 | * - :raw-html-m2r:`@SuperTux88` 68 | - `@SuperTux88 `_ 69 | - 1 70 | * - :raw-html-m2r:`@alcarithemad` 71 | - `@alcarithemad `_ 72 | - 1 73 | * - :raw-html-m2r:`@baby-gnu` 74 | - `@baby-gnu `_ 75 | - 1 76 | * - :raw-html-m2r:`@evverss` 77 | - `@evverss `_ 78 | - 1 79 | * - :raw-html-m2r:`@EvaSDK` 80 | - `@EvaSDK `_ 81 | - 1 82 | * - :raw-html-m2r:`@imran1008` 83 | - `@imran1008 `_ 84 | - 1 85 | * - :raw-html-m2r:`@codekoala` 86 | - `@codekoala `_ 87 | - 1 88 | * - :raw-html-m2r:`@boileaum` 89 | - `@boileaum `_ 90 | - 1 91 | * - :raw-html-m2r:`@noelmcloughlin` 92 | - `@noelmcloughlin `_ 93 | - 1 94 | * - :raw-html-m2r:`@stasjok` 95 | - `@stasjok `_ 96 | - 1 97 | * - :raw-html-m2r:`@babilen` 98 | - `@babilen `_ 99 | - 1 100 | * - :raw-html-m2r:`@lesar` 101 | - `@lesar `_ 102 | - 1 103 | * - :raw-html-m2r:`@puneetk` 104 | - `@puneetk `_ 105 | - 1 106 | 107 | 108 | ---- 109 | 110 | Auto-generated by a `forked version `_ of `gaocegege/maintainer `_ on 2021-10-27. 111 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/pyflakes/test/test_undefined_names.py: -------------------------------------------------------------------------------- 1 | 2 | from _ast import PyCF_ONLY_AST 3 | 4 | from twisted.trial.unittest import TestCase 5 | 6 | from pyflakes import messages as m, checker 7 | from pyflakes.test import harness 8 | 9 | 10 | class Test(harness.Test): 11 | def test_undefined(self): 12 | self.flakes('bar', m.UndefinedName) 13 | 14 | def test_definedInListComp(self): 15 | self.flakes('[a for a in range(10) if a]') 16 | 17 | 18 | def test_functionsNeedGlobalScope(self): 19 | self.flakes(''' 20 | class a: 21 | def b(): 22 | fu 23 | fu = 1 24 | ''') 25 | 26 | def test_builtins(self): 27 | self.flakes('range(10)') 28 | 29 | 30 | def test_magicGlobalsFile(self): 31 | """ 32 | Use of the C{__file__} magic global should not emit an undefined name 33 | warning. 34 | """ 35 | self.flakes('__file__') 36 | 37 | 38 | def test_magicGlobalsBuiltins(self): 39 | """ 40 | Use of the C{__builtins__} magic global should not emit an undefined 41 | name warning. 42 | """ 43 | self.flakes('__builtins__') 44 | 45 | 46 | def test_magicGlobalsName(self): 47 | """ 48 | Use of the C{__name__} magic global should not emit an undefined name 49 | warning. 50 | """ 51 | self.flakes('__name__') 52 | 53 | 54 | def test_magicGlobalsPath(self): 55 | """ 56 | Use of the C{__path__} magic global should not emit an undefined name 57 | warning, if you refer to it from a file called __init__.py. 58 | """ 59 | self.flakes('__path__', m.UndefinedName) 60 | self.flakes('__path__', filename='package/__init__.py') 61 | 62 | 63 | def test_globalImportStar(self): 64 | '''Can't find undefined names with import *''' 65 | self.flakes('from fu import *; bar', m.ImportStarUsed) 66 | 67 | def test_localImportStar(self): 68 | '''A local import * still allows undefined names to be found in upper scopes''' 69 | self.flakes(''' 70 | def a(): 71 | from fu import * 72 | bar 73 | ''', m.ImportStarUsed, m.UndefinedName) 74 | 75 | def test_unpackedParameter(self): 76 | '''Unpacked function parameters create bindings''' 77 | self.flakes(''' 78 | def a((bar, baz)): 79 | bar; baz 80 | ''') 81 | 82 | def test_definedByGlobal(self): 83 | '''"global" can make an otherwise undefined name in another function defined''' 84 | self.flakes(''' 85 | def a(): global fu; fu = 1 86 | def b(): fu 87 | ''') 88 | test_definedByGlobal.todo = '' 89 | 90 | def test_globalInGlobalScope(self): 91 | """ 92 | A global statement in the global scope is ignored. 93 | """ 94 | self.flakes(''' 95 | global x 96 | def foo(): 97 | print x 98 | ''', m.UndefinedName) 99 | 100 | def test_del(self): 101 | '''del deletes bindings''' 102 | self.flakes('a = 1; del a; a', m.UndefinedName) 103 | 104 | def test_delGlobal(self): 105 | '''del a global binding from a function''' 106 | self.flakes(''' 107 | a = 1 108 | def f(): 109 | global a 110 | del a 111 | a 112 | ''') 113 | 114 | def test_delUndefined(self): 115 | '''del an undefined name''' 116 | self.flakes('del a', m.UndefinedName) 117 | 118 | def test_globalFromNestedScope(self): 119 | '''global names are available from nested scopes''' 120 | self.flakes(''' 121 | a = 1 122 | def b(): 123 | def c(): 124 | a 125 | ''') 126 | 127 | def test_laterRedefinedGlobalFromNestedScope(self): 128 | """ 129 | Test that referencing a local name that shadows a global, before it is 130 | defined, generates a warning. 131 | """ 132 | self.flakes(''' 133 | a = 1 134 | def fun(): 135 | a 136 | a = 2 137 | return a 138 | ''', m.UndefinedLocal) 139 | 140 | def test_laterRedefinedGlobalFromNestedScope2(self): 141 | """ 142 | Test that referencing a local name in a nested scope that shadows a 143 | global declared in an enclosing scope, before it is defined, generates 144 | a warning. 145 | """ 146 | self.flakes(''' 147 | a = 1 148 | def fun(): 149 | global a 150 | def fun2(): 151 | a 152 | a = 2 153 | return a 154 | ''', m.UndefinedLocal) 155 | 156 | 157 | def test_intermediateClassScopeIgnored(self): 158 | """ 159 | If a name defined in an enclosing scope is shadowed by a local variable 160 | and the name is used locally before it is bound, an unbound local 161 | warning is emitted, even if there is a class scope between the enclosing 162 | scope and the local scope. 163 | """ 164 | self.flakes(''' 165 | def f(): 166 | x = 1 167 | class g: 168 | def h(self): 169 | a = x 170 | x = None 171 | print x, a 172 | print x 173 | ''', m.UndefinedLocal) 174 | 175 | 176 | def test_doubleNestingReportsClosestName(self): 177 | """ 178 | Test that referencing a local name in a nested scope that shadows a 179 | variable declared in two different outer scopes before it is defined 180 | in the innermost scope generates an UnboundLocal warning which 181 | refers to the nearest shadowed name. 182 | """ 183 | exc = self.flakes(''' 184 | def a(): 185 | x = 1 186 | def b(): 187 | x = 2 # line 5 188 | def c(): 189 | x 190 | x = 3 191 | return x 192 | return x 193 | return x 194 | ''', m.UndefinedLocal).messages[0] 195 | self.assertEqual(exc.message_args, ('x', 5)) 196 | 197 | 198 | def test_laterRedefinedGlobalFromNestedScope3(self): 199 | """ 200 | Test that referencing a local name in a nested scope that shadows a 201 | global, before it is defined, generates a warning. 202 | """ 203 | self.flakes(''' 204 | def fun(): 205 | a = 1 206 | def fun2(): 207 | a 208 | a = 1 209 | return a 210 | return a 211 | ''', m.UndefinedLocal) 212 | 213 | def test_nestedClass(self): 214 | '''nested classes can access enclosing scope''' 215 | self.flakes(''' 216 | def f(foo): 217 | class C: 218 | bar = foo 219 | def f(self): 220 | return foo 221 | return C() 222 | 223 | f(123).f() 224 | ''') 225 | 226 | def test_badNestedClass(self): 227 | '''free variables in nested classes must bind at class creation''' 228 | self.flakes(''' 229 | def f(): 230 | class C: 231 | bar = foo 232 | foo = 456 233 | return foo 234 | f() 235 | ''', m.UndefinedName) 236 | 237 | def test_definedAsStarArgs(self): 238 | '''star and double-star arg names are defined''' 239 | self.flakes(''' 240 | def f(a, *b, **c): 241 | print a, b, c 242 | ''') 243 | 244 | def test_definedInGenExp(self): 245 | """ 246 | Using the loop variable of a generator expression results in no 247 | warnings. 248 | """ 249 | self.flakes('(a for a in xrange(10) if a)') 250 | 251 | 252 | 253 | class NameTests(TestCase): 254 | """ 255 | Tests for some extra cases of name handling. 256 | """ 257 | def test_impossibleContext(self): 258 | """ 259 | A Name node with an unrecognized context results in a RuntimeError being 260 | raised. 261 | """ 262 | tree = compile("x = 10", "", "exec", PyCF_ONLY_AST) 263 | # Make it into something unrecognizable. 264 | tree.body[0].targets[0].ctx = object() 265 | self.assertRaises(RuntimeError, checker.Checker, tree) 266 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | ################################################################################ 5 | # NOTE: This file is UNMAINTAINED; it is provided for references purposes only. 6 | # No guarantees are tendered that this structure will work after 2020. 7 | ################################################################################ 8 | # * https://en.wikipedia.org/wiki/Travis_CI: 9 | # - "... free open-source plans were removed in [sic] the end of 2020" 10 | # - https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing 11 | # - https://ropensci.org/technotes/2020/11/19/moving-away-travis/ 12 | ################################################################################ 13 | ## Machine config 14 | os: 'linux' 15 | arch: 'amd64' 16 | dist: 'bionic' 17 | version: '~> 1.0' 18 | 19 | ## Language and cache config 20 | language: 'ruby' 21 | cache: 'bundler' 22 | 23 | ## Services config 24 | services: 25 | - docker 26 | 27 | ## Script to run for the test stage 28 | script: 29 | - bin/kitchen verify "${INSTANCE}" 30 | 31 | ## Stages and jobs matrix 32 | stages: 33 | - test 34 | # # As part of the switch away from Travis CI, ensure that the `release` stage 35 | # # is not run inadvertently 36 | # - name: 'release' 37 | # if: 'branch = master AND type != pull_request' 38 | jobs: 39 | include: 40 | ## Define the test stage that runs the linters (and testing matrix, if applicable) 41 | 42 | # Run all of the linters in a single job 43 | - language: 'node_js' 44 | node_js: 'lts/*' 45 | env: 'Lint' 46 | name: 'Lint: salt-lint, yamllint, rubocop, shellcheck & commitlint' 47 | before_install: 'skip' 48 | script: 49 | # Install and run `salt-lint` 50 | - pip install --user salt-lint 51 | - git ls-files -- '*.sls' '*.jinja' '*.j2' '*.tmpl' '*.tst' 52 | | xargs salt-lint 53 | # Install and run `yamllint` 54 | # Need at least `v1.17.0` for the `yaml-files` setting 55 | - pip install --user yamllint>=1.17.0 56 | - yamllint -s . 57 | # Install and run `rubocop` 58 | - gem install rubocop 59 | - rubocop -d 60 | # Run `shellcheck` (already pre-installed in Travis) 61 | - shellcheck --version 62 | - git ls-files -- '*.sh' '*.bash' '*.ksh' 63 | | xargs shellcheck 64 | # Install and run `commitlint` 65 | - npm i -D @commitlint/config-conventional 66 | @commitlint/travis-cli 67 | - commitlint-travis 68 | 69 | # Run `pre-commit` linters in a single job 70 | - language: 'python' 71 | env: 'Lint_pre-commit' 72 | name: 'Lint: pre-commit' 73 | before_install: 'skip' 74 | cache: 75 | directories: 76 | - $HOME/.cache/pre-commit 77 | script: 78 | # Install and run `pre-commit` 79 | - pip install pre-commit==2.7.1 80 | - pre-commit run --all-files --color always --verbose 81 | - pre-commit run --color always --hook-stage manual --verbose commitlint-travis 82 | 83 | ## Define the rest of the matrix based on Kitchen testing 84 | # Make sure the instances listed below match up with 85 | # the `platforms` defined in `kitchen.yml` 86 | # - env: INSTANCE=default-debian-11-tiamat-py3 87 | # - env: INSTANCE=default-debian-10-tiamat-py3 88 | # - env: INSTANCE=default-debian-9-tiamat-py3 89 | # - env: INSTANCE=default-ubuntu-2204-tiamat-py3 90 | # - env: INSTANCE=default-ubuntu-2004-tiamat-py3 91 | # - env: INSTANCE=default-ubuntu-1804-tiamat-py3 92 | # - env: INSTANCE=default-centos-stream8-tiamat-py3 93 | # - env: INSTANCE=default-centos-7-tiamat-py3 94 | # - env: INSTANCE=default-amazonlinux-2-tiamat-py3 95 | # - env: INSTANCE=default-oraclelinux-8-tiamat-py3 96 | # - env: INSTANCE=default-oraclelinux-7-tiamat-py3 97 | # - env: INSTANCE=default-almalinux-8-tiamat-py3 98 | # - env: INSTANCE=default-rockylinux-8-tiamat-py3 99 | - env: INSTANCE=default-debian-11-master-py3 100 | - env: INSTANCE=default-debian-10-master-py3 101 | - env: INSTANCE=default-debian-9-master-py3 102 | - env: INSTANCE=default-ubuntu-2204-master-py3 103 | - env: INSTANCE=default-ubuntu-2004-master-py3 104 | - env: INSTANCE=default-ubuntu-1804-master-py3 105 | - env: INSTANCE=default-centos-stream8-master-py3 106 | - env: INSTANCE=default-centos-7-master-py3 107 | - env: INSTANCE=default-fedora-36-master-py3 108 | - env: INSTANCE=default-fedora-35-master-py3 109 | - env: INSTANCE=default-opensuse-leap-153-master-py3 110 | - env: INSTANCE=default-opensuse-tmbl-latest-master-py3 111 | - env: INSTANCE=default-amazonlinux-2-master-py3 112 | - env: INSTANCE=default-oraclelinux-8-master-py3 113 | - env: INSTANCE=default-oraclelinux-7-master-py3 114 | - env: INSTANCE=default-arch-base-latest-master-py3 115 | - env: INSTANCE=default-gentoo-stage3-latest-master-py3 116 | - env: INSTANCE=default-gentoo-stage3-systemd-master-py3 117 | - env: INSTANCE=default-almalinux-8-master-py3 118 | - env: INSTANCE=default-rockylinux-8-master-py3 119 | # - env: INSTANCE=default-debian-11-3004-1-py3 120 | # - env: INSTANCE=default-debian-10-3004-1-py3 121 | # - env: INSTANCE=default-debian-9-3004-1-py3 122 | # - env: INSTANCE=default-ubuntu-2204-3004-1-py3 123 | # - env: INSTANCE=default-ubuntu-2004-3004-1-py3 124 | # - env: INSTANCE=default-ubuntu-1804-3004-1-py3 125 | # - env: INSTANCE=default-centos-stream8-3004-1-py3 126 | # - env: INSTANCE=default-centos-7-3004-1-py3 127 | # - env: INSTANCE=default-fedora-36-3004-1-py3 128 | # - env: INSTANCE=default-fedora-35-3004-1-py3 129 | # - env: INSTANCE=default-amazonlinux-2-3004-1-py3 130 | # - env: INSTANCE=default-oraclelinux-8-3004-1-py3 131 | # - env: INSTANCE=default-oraclelinux-7-3004-1-py3 132 | # - env: INSTANCE=default-arch-base-latest-3004-1-py3 133 | # - env: INSTANCE=default-gentoo-stage3-latest-3004-1-py3 134 | # - env: INSTANCE=default-gentoo-stage3-systemd-3004-1-py3 135 | # - env: INSTANCE=default-almalinux-8-3004-1-py3 136 | # - env: INSTANCE=default-rockylinux-8-3004-1-py3 137 | # - env: INSTANCE=default-opensuse-leap-153-3004-0-py3 138 | # - env: INSTANCE=default-opensuse-tmbl-latest-3004-0-py3 139 | # - env: INSTANCE=default-debian-10-3003-4-py3 140 | # - env: INSTANCE=default-debian-9-3003-4-py3 141 | # - env: INSTANCE=default-ubuntu-2004-3003-4-py3 142 | # - env: INSTANCE=default-ubuntu-1804-3003-4-py3 143 | # - env: INSTANCE=default-centos-stream8-3003-4-py3 144 | # - env: INSTANCE=default-centos-7-3003-4-py3 145 | # - env: INSTANCE=default-amazonlinux-2-3003-4-py3 146 | # - env: INSTANCE=default-oraclelinux-8-3003-4-py3 147 | # - env: INSTANCE=default-oraclelinux-7-3003-4-py3 148 | # - env: INSTANCE=default-almalinux-8-3003-4-py3 149 | 150 | ## Define the release stage that runs `semantic-release` 151 | - stage: 'release' 152 | language: 'node_js' 153 | node_js: 'lts/*' 154 | env: 'Release' 155 | name: 'Run semantic-release inc. file updates to AUTHORS, CHANGELOG & FORMULA' 156 | before_install: 'skip' 157 | script: 158 | # Update `AUTHORS.md` 159 | - export MAINTAINER_TOKEN=${GH_TOKEN} 160 | - go get github.com/myii/maintainer 161 | - maintainer contributor 162 | 163 | # Install all dependencies required for `semantic-release` 164 | - npm i -D @semantic-release/changelog@3 165 | @semantic-release/exec@3 166 | @semantic-release/git@7 167 | deploy: 168 | provider: 'script' 169 | # Opt-in to `dpl v2` to complete the Travis build config validation (beta) 170 | # * https://docs.travis-ci.com/user/build-config-validation 171 | # Deprecated `skip_cleanup` can now be avoided, `cleanup: false` is by default 172 | edge: true 173 | # Run `semantic-release` 174 | script: 'npx semantic-release@15.14' 175 | 176 | # Notification options: `always`, `never` or `change` 177 | notifications: 178 | webhooks: 179 | if: 'repo = saltstack-formulas/vim-formula' 180 | urls: 181 | - https://saltstack-formulas.zulipchat.com/api/v1/external/travis?api_key=HsIq3o5QmLxdnVCKF9is0FUIpkpAY79P&stream=CI&topic=saltstack-formulas%2Fvim-formula&ignore_pull_requests=true 182 | on_success: always # default: always 183 | on_failure: always # default: always 184 | on_start: always # default: never 185 | on_cancel: always # default: always 186 | on_error: always # default: always 187 | -------------------------------------------------------------------------------- /vim/files/nerdtree/nerdtree_plugin/fs_menu.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================ 2 | " File: fs_menu.vim 3 | " Description: plugin for the NERD Tree that provides a file system menu 4 | " Maintainer: Martin Grenfell 5 | " Last Change: 17 July, 2009 6 | " License: This program is free software. It comes without any warranty, 7 | " to the extent permitted by applicable law. You can redistribute 8 | " it and/or modify it under the terms of the Do What The Fuck You 9 | " Want To Public License, Version 2, as published by Sam Hocevar. 10 | " See http://sam.zoy.org/wtfpl/COPYING for more details. 11 | " 12 | " ============================================================================ 13 | if exists("g:loaded_nerdtree_fs_menu") 14 | finish 15 | endif 16 | let g:loaded_nerdtree_fs_menu = 1 17 | 18 | call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) 19 | call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) 20 | call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) 21 | 22 | if has("gui_mac") || has("gui_macvim") 23 | call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) 24 | call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'}) 25 | call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'}) 26 | endif 27 | 28 | if g:NERDTreePath.CopyingSupported() 29 | call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) 30 | endif 31 | 32 | "FUNCTION: s:echo(msg){{{1 33 | function! s:echo(msg) 34 | redraw 35 | echomsg "NERDTree: " . a:msg 36 | endfunction 37 | 38 | "FUNCTION: s:echoWarning(msg){{{1 39 | function! s:echoWarning(msg) 40 | echohl warningmsg 41 | call s:echo(a:msg) 42 | echohl normal 43 | endfunction 44 | 45 | "FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1 46 | "prints out the given msg and, if the user responds by pushing 'y' then the 47 | "buffer with the given bufnum is deleted 48 | " 49 | "Args: 50 | "bufnum: the buffer that may be deleted 51 | "msg: a message that will be echoed to the user asking them if they wish to 52 | " del the buffer 53 | function! s:promptToDelBuffer(bufnum, msg) 54 | echo a:msg 55 | if nr2char(getchar()) ==# 'y' 56 | exec "silent bdelete! " . a:bufnum 57 | endif 58 | endfunction 59 | 60 | "FUNCTION: NERDTreeAddNode(){{{1 61 | function! NERDTreeAddNode() 62 | let curDirNode = g:NERDTreeDirNode.GetSelected() 63 | 64 | let newNodeName = input("Add a childnode\n". 65 | \ "==========================================================\n". 66 | \ "Enter the dir/file name to be created. Dirs end with a '/'\n" . 67 | \ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file") 68 | 69 | if newNodeName ==# '' 70 | call s:echo("Node Creation Aborted.") 71 | return 72 | endif 73 | 74 | try 75 | let newPath = g:NERDTreePath.Create(newNodeName) 76 | let parentNode = b:NERDTreeRoot.findNode(newPath.getParent()) 77 | 78 | let newTreeNode = g:NERDTreeFileNode.New(newPath) 79 | if parentNode.isOpen || !empty(parentNode.children) 80 | call parentNode.addChild(newTreeNode, 1) 81 | call NERDTreeRender() 82 | call newTreeNode.putCursorHere(1, 0) 83 | endif 84 | catch /^NERDTree/ 85 | call s:echoWarning("Node Not Created.") 86 | endtry 87 | endfunction 88 | 89 | "FUNCTION: NERDTreeMoveNode(){{{1 90 | function! NERDTreeMoveNode() 91 | let curNode = g:NERDTreeFileNode.GetSelected() 92 | let newNodePath = input("Rename the current node\n" . 93 | \ "==========================================================\n" . 94 | \ "Enter the new path for the node: \n" . 95 | \ "", curNode.path.str(), "file") 96 | 97 | if newNodePath ==# '' 98 | call s:echo("Node Renaming Aborted.") 99 | return 100 | endif 101 | 102 | try 103 | let bufnum = bufnr(curNode.path.str()) 104 | 105 | call curNode.rename(newNodePath) 106 | call NERDTreeRender() 107 | 108 | "if the node is open in a buffer, ask the user if they want to 109 | "close that buffer 110 | if bufnum != -1 111 | let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" 112 | call s:promptToDelBuffer(bufnum, prompt) 113 | endif 114 | 115 | call curNode.putCursorHere(1, 0) 116 | 117 | redraw 118 | catch /^NERDTree/ 119 | call s:echoWarning("Node Not Renamed.") 120 | endtry 121 | endfunction 122 | 123 | " FUNCTION: NERDTreeDeleteNode() {{{1 124 | function! NERDTreeDeleteNode() 125 | let currentNode = g:NERDTreeFileNode.GetSelected() 126 | let confirmed = 0 127 | 128 | if currentNode.path.isDirectory 129 | let choice =input("Delete the current node\n" . 130 | \ "==========================================================\n" . 131 | \ "STOP! To delete this entire directory, type 'yes'\n" . 132 | \ "" . currentNode.path.str() . ": ") 133 | let confirmed = choice ==# 'yes' 134 | else 135 | echo "Delete the current node\n" . 136 | \ "==========================================================\n". 137 | \ "Are you sure you wish to delete the node:\n" . 138 | \ "" . currentNode.path.str() . " (yN):" 139 | let choice = nr2char(getchar()) 140 | let confirmed = choice ==# 'y' 141 | endif 142 | 143 | 144 | if confirmed 145 | try 146 | call currentNode.delete() 147 | call NERDTreeRender() 148 | 149 | "if the node is open in a buffer, ask the user if they want to 150 | "close that buffer 151 | let bufnum = bufnr(currentNode.path.str()) 152 | if buflisted(bufnum) 153 | let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" 154 | call s:promptToDelBuffer(bufnum, prompt) 155 | endif 156 | 157 | redraw 158 | catch /^NERDTree/ 159 | call s:echoWarning("Could not remove node") 160 | endtry 161 | else 162 | call s:echo("delete aborted") 163 | endif 164 | 165 | endfunction 166 | 167 | " FUNCTION: NERDTreeCopyNode() {{{1 168 | function! NERDTreeCopyNode() 169 | let currentNode = g:NERDTreeFileNode.GetSelected() 170 | let newNodePath = input("Copy the current node\n" . 171 | \ "==========================================================\n" . 172 | \ "Enter the new path to copy the node to: \n" . 173 | \ "", currentNode.path.str(), "file") 174 | 175 | if newNodePath != "" 176 | "strip trailing slash 177 | let newNodePath = substitute(newNodePath, '\/$', '', '') 178 | 179 | let confirmed = 1 180 | if currentNode.path.copyingWillOverwrite(newNodePath) 181 | call s:echo("Warning: copying may overwrite files! Continue? (yN)") 182 | let choice = nr2char(getchar()) 183 | let confirmed = choice ==# 'y' 184 | endif 185 | 186 | if confirmed 187 | try 188 | let newNode = currentNode.copy(newNodePath) 189 | if !empty(newNode) 190 | call NERDTreeRender() 191 | call newNode.putCursorHere(0, 0) 192 | endif 193 | catch /^NERDTree/ 194 | call s:echoWarning("Could not copy node") 195 | endtry 196 | endif 197 | else 198 | call s:echo("Copy aborted.") 199 | endif 200 | redraw 201 | endfunction 202 | 203 | function! NERDTreeQuickLook() 204 | let treenode = g:NERDTreeFileNode.GetSelected() 205 | if treenode != {} 206 | call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'") 207 | endif 208 | endfunction 209 | 210 | function! NERDTreeRevealInFinder() 211 | let treenode = g:NERDTreeFileNode.GetSelected() 212 | if treenode != {} 213 | let x = system("open -R '" . treenode.path.str() . "'") 214 | endif 215 | endfunction 216 | 217 | function! NERDTreeExecuteFile() 218 | let treenode = g:NERDTreeFileNode.GetSelected() 219 | if treenode != {} 220 | let x = system("open '" . treenode.path.str() . "'") 221 | endif 222 | endfunction 223 | 224 | " vim: set sw=4 sts=4 et fdm=marker: 225 | -------------------------------------------------------------------------------- /kitchen.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | # For help on this file's format, see https://kitchen.ci/ 5 | driver: 6 | name: docker 7 | use_sudo: false 8 | privileged: true 9 | run_command: /usr/lib/systemd/systemd 10 | 11 | provisioner: 12 | name: salt_solo 13 | log_level: debug 14 | salt_install: none 15 | require_chef: false 16 | formula: vim 17 | salt_copy_filter: 18 | - .kitchen 19 | - .git 20 | 21 | platforms: 22 | ## SALT `tiamat` 23 | - name: debian-11-tiamat-py3 24 | driver: 25 | image: saltimages/salt-tiamat-py3:debian-11 26 | run_command: /lib/systemd/systemd 27 | - name: debian-10-tiamat-py3 28 | driver: 29 | image: saltimages/salt-tiamat-py3:debian-10 30 | run_command: /lib/systemd/systemd 31 | - name: debian-9-tiamat-py3 32 | driver: 33 | image: saltimages/salt-tiamat-py3:debian-9 34 | run_command: /lib/systemd/systemd 35 | - name: ubuntu-2204-tiamat-py3 36 | driver: 37 | image: saltimages/salt-tiamat-py3:ubuntu-22.04 38 | run_command: /lib/systemd/systemd 39 | - name: ubuntu-2004-tiamat-py3 40 | driver: 41 | image: saltimages/salt-tiamat-py3:ubuntu-20.04 42 | run_command: /lib/systemd/systemd 43 | - name: ubuntu-1804-tiamat-py3 44 | driver: 45 | image: saltimages/salt-tiamat-py3:ubuntu-18.04 46 | run_command: /lib/systemd/systemd 47 | - name: centos-stream8-tiamat-py3 48 | driver: 49 | image: saltimages/salt-tiamat-py3:centos-stream8 50 | - name: centos-7-tiamat-py3 51 | driver: 52 | image: saltimages/salt-tiamat-py3:centos-7 53 | - name: amazonlinux-2-tiamat-py3 54 | driver: 55 | image: saltimages/salt-tiamat-py3:amazonlinux-2 56 | - name: oraclelinux-8-tiamat-py3 57 | driver: 58 | image: saltimages/salt-tiamat-py3:oraclelinux-8 59 | - name: oraclelinux-7-tiamat-py3 60 | driver: 61 | image: saltimages/salt-tiamat-py3:oraclelinux-7 62 | - name: almalinux-8-tiamat-py3 63 | driver: 64 | image: saltimages/salt-tiamat-py3:almalinux-8 65 | - name: rockylinux-8-tiamat-py3 66 | driver: 67 | image: saltimages/salt-tiamat-py3:rockylinux-8 68 | 69 | ## SALT `master` 70 | - name: debian-11-master-py3 71 | driver: 72 | image: saltimages/salt-master-py3:debian-11 73 | run_command: /lib/systemd/systemd 74 | - name: debian-10-master-py3 75 | driver: 76 | image: saltimages/salt-master-py3:debian-10 77 | run_command: /lib/systemd/systemd 78 | - name: debian-9-master-py3 79 | driver: 80 | image: saltimages/salt-master-py3:debian-9 81 | run_command: /lib/systemd/systemd 82 | - name: ubuntu-2204-master-py3 83 | driver: 84 | image: saltimages/salt-master-py3:ubuntu-22.04 85 | run_command: /lib/systemd/systemd 86 | - name: ubuntu-2004-master-py3 87 | driver: 88 | image: saltimages/salt-master-py3:ubuntu-20.04 89 | run_command: /lib/systemd/systemd 90 | - name: ubuntu-1804-master-py3 91 | driver: 92 | image: saltimages/salt-master-py3:ubuntu-18.04 93 | run_command: /lib/systemd/systemd 94 | - name: centos-stream8-master-py3 95 | driver: 96 | image: saltimages/salt-master-py3:centos-stream8 97 | - name: centos-7-master-py3 98 | driver: 99 | image: saltimages/salt-master-py3:centos-7 100 | - name: fedora-36-master-py3 101 | driver: 102 | image: saltimages/salt-master-py3:fedora-36 103 | - name: fedora-35-master-py3 104 | driver: 105 | image: saltimages/salt-master-py3:fedora-35 106 | - name: opensuse-leap-153-master-py3 107 | driver: 108 | image: saltimages/salt-master-py3:opensuse-leap-15.3 109 | # Workaround to avoid intermittent failures on `opensuse-leap-15.3`: 110 | # => SCP did not finish successfully (255): (Net::SCP::Error) 111 | transport: 112 | max_ssh_sessions: 1 113 | - name: opensuse-tmbl-latest-master-py3 114 | driver: 115 | image: saltimages/salt-master-py3:opensuse-tumbleweed-latest 116 | # Workaround to avoid intermittent failures on `opensuse-tumbleweed`: 117 | # => SCP did not finish successfully (255): (Net::SCP::Error) 118 | transport: 119 | max_ssh_sessions: 1 120 | - name: amazonlinux-2-master-py3 121 | driver: 122 | image: saltimages/salt-master-py3:amazonlinux-2 123 | - name: oraclelinux-8-master-py3 124 | driver: 125 | image: saltimages/salt-master-py3:oraclelinux-8 126 | - name: oraclelinux-7-master-py3 127 | driver: 128 | image: saltimages/salt-master-py3:oraclelinux-7 129 | - name: arch-base-latest-master-py3 130 | driver: 131 | image: saltimages/salt-master-py3:arch-base-latest 132 | - name: gentoo-stage3-latest-master-py3 133 | driver: 134 | image: saltimages/salt-master-py3:gentoo-stage3-latest 135 | run_command: /sbin/init 136 | - name: gentoo-stage3-systemd-master-py3 137 | driver: 138 | image: saltimages/salt-master-py3:gentoo-stage3-systemd 139 | - name: almalinux-8-master-py3 140 | driver: 141 | image: saltimages/salt-master-py3:almalinux-8 142 | - name: rockylinux-8-master-py3 143 | driver: 144 | image: saltimages/salt-master-py3:rockylinux-8 145 | 146 | ## SALT `3004.1` 147 | - name: debian-11-3004-1-py3 148 | driver: 149 | image: saltimages/salt-3004.1-py3:debian-11 150 | run_command: /lib/systemd/systemd 151 | - name: debian-10-3004-1-py3 152 | driver: 153 | image: saltimages/salt-3004.1-py3:debian-10 154 | run_command: /lib/systemd/systemd 155 | - name: debian-9-3004-1-py3 156 | driver: 157 | image: saltimages/salt-3004.1-py3:debian-9 158 | run_command: /lib/systemd/systemd 159 | - name: ubuntu-2204-3004-1-py3 160 | driver: 161 | image: saltimages/salt-3004.1-py3:ubuntu-22.04 162 | run_command: /lib/systemd/systemd 163 | - name: ubuntu-2004-3004-1-py3 164 | driver: 165 | image: saltimages/salt-3004.1-py3:ubuntu-20.04 166 | run_command: /lib/systemd/systemd 167 | - name: ubuntu-1804-3004-1-py3 168 | driver: 169 | image: saltimages/salt-3004.1-py3:ubuntu-18.04 170 | run_command: /lib/systemd/systemd 171 | - name: centos-stream8-3004-1-py3 172 | driver: 173 | image: saltimages/salt-3004.1-py3:centos-stream8 174 | - name: centos-7-3004-1-py3 175 | driver: 176 | image: saltimages/salt-3004.1-py3:centos-7 177 | - name: fedora-36-3004-1-py3 178 | driver: 179 | image: saltimages/salt-3004.1-py3:fedora-36 180 | - name: fedora-35-3004-1-py3 181 | driver: 182 | image: saltimages/salt-3004.1-py3:fedora-35 183 | - name: amazonlinux-2-3004-1-py3 184 | driver: 185 | image: saltimages/salt-3004.1-py3:amazonlinux-2 186 | - name: oraclelinux-8-3004-1-py3 187 | driver: 188 | image: saltimages/salt-3004.1-py3:oraclelinux-8 189 | - name: oraclelinux-7-3004-1-py3 190 | driver: 191 | image: saltimages/salt-3004.1-py3:oraclelinux-7 192 | - name: arch-base-latest-3004-1-py3 193 | driver: 194 | image: saltimages/salt-3004.1-py3:arch-base-latest 195 | - name: gentoo-stage3-latest-3004-1-py3 196 | driver: 197 | image: saltimages/salt-3004.1-py3:gentoo-stage3-latest 198 | run_command: /sbin/init 199 | - name: gentoo-stage3-systemd-3004-1-py3 200 | driver: 201 | image: saltimages/salt-3004.1-py3:gentoo-stage3-systemd 202 | - name: almalinux-8-3004-1-py3 203 | driver: 204 | image: saltimages/salt-3004.1-py3:almalinux-8 205 | - name: rockylinux-8-3004-1-py3 206 | driver: 207 | image: saltimages/salt-3004.1-py3:rockylinux-8 208 | 209 | ## SALT `3004.0` 210 | - name: opensuse-leap-153-3004-0-py3 211 | driver: 212 | image: saltimages/salt-3004.0-py3:opensuse-leap-15.3 213 | # Workaround to avoid intermittent failures on `opensuse-leap-15.3`: 214 | # => SCP did not finish successfully (255): (Net::SCP::Error) 215 | transport: 216 | max_ssh_sessions: 1 217 | - name: opensuse-tmbl-latest-3004-0-py3 218 | driver: 219 | image: saltimages/salt-3004.0-py3:opensuse-tumbleweed-latest 220 | # Workaround to avoid intermittent failures on `opensuse-tumbleweed`: 221 | # => SCP did not finish successfully (255): (Net::SCP::Error) 222 | transport: 223 | max_ssh_sessions: 1 224 | 225 | ## SALT `3003.4` 226 | - name: debian-10-3003-4-py3 227 | driver: 228 | image: saltimages/salt-3003.4-py3:debian-10 229 | run_command: /lib/systemd/systemd 230 | - name: debian-9-3003-4-py3 231 | driver: 232 | image: saltimages/salt-3003.4-py3:debian-9 233 | run_command: /lib/systemd/systemd 234 | - name: ubuntu-2004-3003-4-py3 235 | driver: 236 | image: saltimages/salt-3003.4-py3:ubuntu-20.04 237 | run_command: /lib/systemd/systemd 238 | - name: ubuntu-1804-3003-4-py3 239 | driver: 240 | image: saltimages/salt-3003.4-py3:ubuntu-18.04 241 | run_command: /lib/systemd/systemd 242 | - name: centos-stream8-3003-4-py3 243 | driver: 244 | image: saltimages/salt-3003.4-py3:centos-stream8 245 | - name: centos-7-3003-4-py3 246 | driver: 247 | image: saltimages/salt-3003.4-py3:centos-7 248 | - name: amazonlinux-2-3003-4-py3 249 | driver: 250 | image: saltimages/salt-3003.4-py3:amazonlinux-2 251 | - name: oraclelinux-8-3003-4-py3 252 | driver: 253 | image: saltimages/salt-3003.4-py3:oraclelinux-8 254 | - name: oraclelinux-7-3003-4-py3 255 | driver: 256 | image: saltimages/salt-3003.4-py3:oraclelinux-7 257 | - name: almalinux-8-3003-4-py3 258 | driver: 259 | image: saltimages/salt-3003.4-py3:almalinux-8 260 | 261 | verifier: 262 | # https://www.inspec.io/ 263 | name: inspec 264 | sudo: true 265 | reporter: 266 | # cli, documentation, html, progress, json, json-min, json-rspec, junit 267 | - cli 268 | 269 | suites: 270 | - name: default 271 | provisioner: 272 | state_top: 273 | base: 274 | '*': 275 | - vim._mapdata 276 | - vim 277 | pillars: 278 | top.sls: 279 | base: 280 | '*': 281 | - vim 282 | pillars_from_files: 283 | vim.sls: test/salt/pillar/vim.sls 284 | verifier: 285 | inspec_tests: 286 | - path: test/integration/default 287 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # vim: ft=yaml 3 | --- 4 | ############################################################################### 5 | # Define all YAML node anchors 6 | ############################################################################### 7 | .node_anchors: 8 | # `only` (also used for `except` where applicable) 9 | only_branch_master_parent_repo: &only_branch_master_parent_repo 10 | - 'master@saltstack-formulas/vim-formula' 11 | # `stage` 12 | stage_lint: &stage_lint 'lint' 13 | stage_release: &stage_release 'release' 14 | stage_test: &stage_test 'test' 15 | # `image` 16 | image_commitlint: &image_commitlint 'myii/ssf-commitlint:11' 17 | image_dindruby: &image_dindruby 'myii/ssf-dind-ruby:2.7.1-r3' 18 | image_precommit: &image_precommit 19 | name: 'myii/ssf-pre-commit:2.9.2' 20 | entrypoint: ['/bin/bash', '-c'] 21 | image_rubocop: &image_rubocop 'pipelinecomponents/rubocop:latest' 22 | image_semantic-release: &image_semanticrelease 'myii/ssf-semantic-release:15.14' 23 | # `services` 24 | services_docker_dind: &services_docker_dind 25 | - 'docker:dind' 26 | # `variables` 27 | # https://forum.gitlab.com/t/gitlab-com-ci-caching-rubygems/5627/3 28 | # https://bundler.io/v1.16/bundle_config.html 29 | variables_bundler: &variables_bundler 30 | BUNDLE_CACHE_PATH: '${CI_PROJECT_DIR}/.cache/bundler' 31 | BUNDLE_WITHOUT: 'production' 32 | # `cache` 33 | cache_bundler: &cache_bundler 34 | key: '${CI_JOB_STAGE}' 35 | paths: 36 | - '${BUNDLE_CACHE_PATH}' 37 | 38 | ############################################################################### 39 | # Define stages and global variables 40 | ############################################################################### 41 | stages: 42 | - *stage_lint 43 | - *stage_test 44 | - *stage_release 45 | variables: 46 | DOCKER_DRIVER: 'overlay2' 47 | 48 | ############################################################################### 49 | # `lint` stage: `commitlint`, `pre-commit` & `rubocop` (latest, failure allowed) 50 | ############################################################################### 51 | commitlint: 52 | stage: *stage_lint 53 | image: *image_commitlint 54 | script: 55 | # Add `upstream` remote to get access to `upstream/master` 56 | - 'git remote add upstream 57 | https://gitlab.com/saltstack-formulas/vim-formula.git' 58 | - 'git fetch --all' 59 | # Set default commit hashes for `--from` and `--to` 60 | - 'export COMMITLINT_FROM="$(git merge-base upstream/master HEAD)"' 61 | - 'export COMMITLINT_TO="${CI_COMMIT_SHA}"' 62 | # `coqbot` adds a merge commit to test PRs on top of the latest commit in 63 | # the repo; amend this merge commit message to avoid failure 64 | - | 65 | if [ "${GITLAB_USER_LOGIN}" = "coqbot" ] \ 66 | && [ "${CI_COMMIT_BRANCH}" != "master" ]; then 67 | git commit --amend -m \ 68 | 'chore: reword coqbot merge commit message for commitlint' 69 | export COMMITLINT_TO=HEAD 70 | fi 71 | # Run `commitlint` 72 | - 'commitlint --from "${COMMITLINT_FROM}" 73 | --to "${COMMITLINT_TO}" 74 | --verbose' 75 | 76 | pre-commit: 77 | stage: *stage_lint 78 | image: *image_precommit 79 | # https://pre-commit.com/#gitlab-ci-example 80 | variables: 81 | PRE_COMMIT_HOME: '${CI_PROJECT_DIR}/.cache/pre-commit' 82 | cache: 83 | key: '${CI_JOB_NAME}' 84 | paths: 85 | - '${PRE_COMMIT_HOME}' 86 | script: 87 | - 'pre-commit run --all-files --color always --verbose' 88 | 89 | # Use a separate job for `rubocop` other than the one potentially run by `pre-commit` 90 | # - The `pre-commit` check will only be available for formulas that pass the default 91 | # `rubocop` check -- and must continue to do so 92 | # - This job is allowed to fail, so can be used for all formulas 93 | # - Furthermore, this job uses all of the latest `rubocop` features & cops, 94 | # which will help when upgrading the `rubocop` linter used in `pre-commit` 95 | rubocop: 96 | allow_failure: true 97 | stage: *stage_lint 98 | image: *image_rubocop 99 | script: 100 | - 'rubocop -d -P -S --enable-pending-cops' 101 | 102 | ############################################################################### 103 | # Define `test` template 104 | ############################################################################### 105 | .test_instance: &test_instance 106 | stage: *stage_test 107 | image: *image_dindruby 108 | services: *services_docker_dind 109 | variables: *variables_bundler 110 | cache: *cache_bundler 111 | before_script: 112 | # TODO: This should work from the env vars above automatically 113 | - 'bundle config set path "${BUNDLE_CACHE_PATH}"' 114 | - 'bundle config set without "${BUNDLE_WITHOUT}"' 115 | - 'bundle install' 116 | script: 117 | # Alternative value to consider: `${CI_JOB_NAME}` 118 | - 'bin/kitchen verify "${DOCKER_ENV_CI_JOB_NAME}"' 119 | 120 | ############################################################################### 121 | # Define `test` template (`allow_failure: true`) 122 | ############################################################################### 123 | .test_instance_failure_permitted: 124 | <<: *test_instance 125 | allow_failure: true 126 | 127 | ############################################################################### 128 | # `test` stage: each instance below uses the `test` template above 129 | ############################################################################### 130 | ## Define the rest of the matrix based on Kitchen testing 131 | # Make sure the instances listed below match up with 132 | # the `platforms` defined in `kitchen.yml` 133 | # yamllint disable rule:line-length 134 | # default-debian-11-tiamat-py3: {extends: '.test_instance'} 135 | # default-debian-10-tiamat-py3: {extends: '.test_instance'} 136 | # default-debian-9-tiamat-py3: {extends: '.test_instance'} 137 | # default-ubuntu-2204-tiamat-py3: {extends: '.test_instance_failure_permitted'} 138 | # default-ubuntu-2004-tiamat-py3: {extends: '.test_instance'} 139 | # default-ubuntu-1804-tiamat-py3: {extends: '.test_instance'} 140 | # default-centos-stream8-tiamat-py3: {extends: '.test_instance_failure_permitted'} 141 | # default-centos-7-tiamat-py3: {extends: '.test_instance'} 142 | # default-amazonlinux-2-tiamat-py3: {extends: '.test_instance'} 143 | # default-oraclelinux-8-tiamat-py3: {extends: '.test_instance'} 144 | # default-oraclelinux-7-tiamat-py3: {extends: '.test_instance'} 145 | # default-almalinux-8-tiamat-py3: {extends: '.test_instance'} 146 | # default-rockylinux-8-tiamat-py3: {extends: '.test_instance'} 147 | default-debian-11-master-py3: {extends: '.test_instance'} 148 | default-debian-10-master-py3: {extends: '.test_instance'} 149 | default-debian-9-master-py3: {extends: '.test_instance'} 150 | default-ubuntu-2204-master-py3: {extends: '.test_instance_failure_permitted'} 151 | default-ubuntu-2004-master-py3: {extends: '.test_instance'} 152 | default-ubuntu-1804-master-py3: {extends: '.test_instance'} 153 | default-centos-stream8-master-py3: {extends: '.test_instance_failure_permitted'} 154 | default-centos-7-master-py3: {extends: '.test_instance'} 155 | default-fedora-36-master-py3: {extends: '.test_instance_failure_permitted'} 156 | default-fedora-35-master-py3: {extends: '.test_instance'} 157 | default-opensuse-leap-153-master-py3: {extends: '.test_instance'} 158 | default-opensuse-tmbl-latest-master-py3: {extends: '.test_instance_failure_permitted'} 159 | default-amazonlinux-2-master-py3: {extends: '.test_instance'} 160 | default-oraclelinux-8-master-py3: {extends: '.test_instance'} 161 | default-oraclelinux-7-master-py3: {extends: '.test_instance'} 162 | default-arch-base-latest-master-py3: {extends: '.test_instance'} 163 | default-gentoo-stage3-latest-master-py3: {extends: '.test_instance'} 164 | default-gentoo-stage3-systemd-master-py3: {extends: '.test_instance'} 165 | default-almalinux-8-master-py3: {extends: '.test_instance'} 166 | default-rockylinux-8-master-py3: {extends: '.test_instance'} 167 | # default-debian-11-3004-1-py3: {extends: '.test_instance'} 168 | # default-debian-10-3004-1-py3: {extends: '.test_instance'} 169 | # default-debian-9-3004-1-py3: {extends: '.test_instance'} 170 | # default-ubuntu-2204-3004-1-py3: {extends: '.test_instance_failure_permitted'} 171 | # default-ubuntu-2004-3004-1-py3: {extends: '.test_instance'} 172 | # default-ubuntu-1804-3004-1-py3: {extends: '.test_instance'} 173 | # default-centos-stream8-3004-1-py3: {extends: '.test_instance_failure_permitted'} 174 | # default-centos-7-3004-1-py3: {extends: '.test_instance'} 175 | # default-fedora-36-3004-1-py3: {extends: '.test_instance_failure_permitted'} 176 | # default-fedora-35-3004-1-py3: {extends: '.test_instance'} 177 | # default-amazonlinux-2-3004-1-py3: {extends: '.test_instance'} 178 | # default-oraclelinux-8-3004-1-py3: {extends: '.test_instance'} 179 | # default-oraclelinux-7-3004-1-py3: {extends: '.test_instance'} 180 | # default-arch-base-latest-3004-1-py3: {extends: '.test_instance'} 181 | # default-gentoo-stage3-latest-3004-1-py3: {extends: '.test_instance'} 182 | # default-gentoo-stage3-systemd-3004-1-py3: {extends: '.test_instance'} 183 | # default-almalinux-8-3004-1-py3: {extends: '.test_instance'} 184 | # default-rockylinux-8-3004-1-py3: {extends: '.test_instance'} 185 | # default-opensuse-leap-153-3004-0-py3: {extends: '.test_instance'} 186 | # default-opensuse-tmbl-latest-3004-0-py3: {extends: '.test_instance_failure_permitted'} 187 | # default-debian-10-3003-4-py3: {extends: '.test_instance'} 188 | # default-debian-9-3003-4-py3: {extends: '.test_instance'} 189 | # default-ubuntu-2004-3003-4-py3: {extends: '.test_instance'} 190 | # default-ubuntu-1804-3003-4-py3: {extends: '.test_instance'} 191 | # default-centos-stream8-3003-4-py3: {extends: '.test_instance_failure_permitted'} 192 | # default-centos-7-3003-4-py3: {extends: '.test_instance'} 193 | # default-amazonlinux-2-3003-4-py3: {extends: '.test_instance'} 194 | # default-oraclelinux-8-3003-4-py3: {extends: '.test_instance'} 195 | # default-oraclelinux-7-3003-4-py3: {extends: '.test_instance'} 196 | # default-almalinux-8-3003-4-py3: {extends: '.test_instance'} 197 | # yamllint enable rule:line-length 198 | 199 | ############################################################################### 200 | # `release` stage: `semantic-release` 201 | ############################################################################### 202 | semantic-release: 203 | only: *only_branch_master_parent_repo 204 | stage: *stage_release 205 | image: *image_semanticrelease 206 | variables: 207 | MAINTAINER_TOKEN: '${GH_TOKEN}' 208 | script: 209 | # Update `AUTHORS.md` 210 | - '${HOME}/go/bin/maintainer contributor' 211 | # Run `semantic-release` 212 | - 'semantic-release' 213 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [0.15.5](https://github.com/saltstack-formulas/vim-formula/compare/v0.15.4...v0.15.5) (2021-10-27) 4 | 5 | 6 | ### Bug Fixes 7 | 8 | * **init:** remove duplicate `template: jinja` line ([f83bb1b](https://github.com/saltstack-formulas/vim-formula/commit/f83bb1bf39dbfbb1be917bd45be1081c1545b29c)), closes [#52](https://github.com/saltstack-formulas/vim-formula/issues/52) [#51](https://github.com/saltstack-formulas/vim-formula/issues/51) 9 | 10 | 11 | ### Continuous Integration 12 | 13 | * **3003.1:** update inc. AlmaLinux, Rocky & `rst-lint` [skip ci] ([60bd7fa](https://github.com/saltstack-formulas/vim-formula/commit/60bd7fab56325c56f68efb69463a7224ecf7e7b3)) 14 | * **gemfile+lock:** use `ssf` customised `inspec` repo [skip ci] ([a411383](https://github.com/saltstack-formulas/vim-formula/commit/a411383a167aa900204f4dc1942a36ea82eed469)) 15 | * **kitchen:** move `provisioner` block & update `run_command` [skip ci] ([0a671a7](https://github.com/saltstack-formulas/vim-formula/commit/0a671a7eee039873b72992b947eec939bae9df8d)) 16 | * **kitchen+ci:** update with latest `3003.2` pre-salted images [skip ci] ([4bcede1](https://github.com/saltstack-formulas/vim-formula/commit/4bcede1b82c60adbc575ecc8a6ffa050fffbec27)) 17 | * **kitchen+ci:** update with latest CVE pre-salted images [skip ci] ([12f3254](https://github.com/saltstack-formulas/vim-formula/commit/12f32543c029e132ba3de785f3a9d39beb4b58e8)) 18 | * add `arch-master` to matrix and update `.travis.yml` [skip ci] ([a659899](https://github.com/saltstack-formulas/vim-formula/commit/a6598996ca647632a12e4441b6df37bf2523972d)) 19 | * add Debian 11 Bullseye & update `yamllint` configuration [skip ci] ([305701d](https://github.com/saltstack-formulas/vim-formula/commit/305701d3a544505831a91d1b18039b0c14369c01)) 20 | * **kitchen+ci:** use latest pre-salted images (after CVE) [skip ci] ([82c9074](https://github.com/saltstack-formulas/vim-formula/commit/82c9074bef507b38a2505d8bf828e8303c989836)) 21 | * **kitchen+gitlab:** adjust matrix to add `3003` [skip ci] ([e4e58d4](https://github.com/saltstack-formulas/vim-formula/commit/e4e58d47779a420bfc283ac26f1c40f6e8804544)) 22 | * **kitchen+gitlab:** remove Ubuntu 16.04 & Fedora 32 (EOL) [skip ci] ([516042f](https://github.com/saltstack-formulas/vim-formula/commit/516042f710e04971327cffd0c24218ec91ea238d)) 23 | 24 | 25 | ### Tests 26 | 27 | * standardise use of `share` suite & `_mapdata` state [skip ci] ([90a3fdc](https://github.com/saltstack-formulas/vim-formula/commit/90a3fdc55d04ffcc4bc750aee26d71f0e831f6b4)) 28 | 29 | ## [0.15.4](https://github.com/saltstack-formulas/vim-formula/compare/v0.15.3...v0.15.4) (2021-03-01) 30 | 31 | 32 | ### Bug Fixes 33 | 34 | * **vim/init.sls:** fix full vim installation on suse ([bc5283f](https://github.com/saltstack-formulas/vim-formula/commit/bc5283fc135b6a258c0df542fd07d7d339f47993)) 35 | 36 | 37 | ### Continuous Integration 38 | 39 | * **commitlint:** ensure `upstream/master` uses main repo URL [skip ci] ([e67e88a](https://github.com/saltstack-formulas/vim-formula/commit/e67e88af4b14970e5e3cb8c8d54a28bd43244b3a)) 40 | * **gemfile+lock:** use `ssf` customised `kitchen-docker` repo [skip ci] ([0e62788](https://github.com/saltstack-formulas/vim-formula/commit/0e627889ca6f0b78592ef0c71331310567415fb6)) 41 | * **gitlab-ci:** add `rubocop` linter (with `allow_failure`) [skip ci] ([225875d](https://github.com/saltstack-formulas/vim-formula/commit/225875d9b5db83efe5b245c131b4eafc682513bb)) 42 | * **kitchen+gitlab-ci:** use latest pre-salted images [skip ci] ([9b340fd](https://github.com/saltstack-formulas/vim-formula/commit/9b340fd61380d7cd13fe5c07e0c7c95bdb87ebd3)) 43 | * **pre-commit:** update hook for `rubocop` [skip ci] ([ae2b632](https://github.com/saltstack-formulas/vim-formula/commit/ae2b6321700c8e8ea365b8d255ac716ebd88ab6d)) 44 | 45 | 46 | ### Tests 47 | 48 | * **package_spec:** adjust to work across all platforms ([e969de0](https://github.com/saltstack-formulas/vim-formula/commit/e969de0da918210cd5093ed2dd9e5478e895c95b)) 49 | 50 | ## [0.15.3](https://github.com/saltstack-formulas/vim-formula/compare/v0.15.2...v0.15.3) (2020-12-16) 51 | 52 | 53 | ### Bug Fixes 54 | 55 | * **release.config.js:** use full commit hash in commit link [skip ci] ([9f512da](https://github.com/saltstack-formulas/vim-formula/commit/9f512dadd08767afe69d04ede87e0b028e1ef810)) 56 | 57 | 58 | ### Continuous Integration 59 | 60 | * **gemfile:** restrict `train` gem version until upstream fix [skip ci] ([01d3a15](https://github.com/saltstack-formulas/vim-formula/commit/01d3a15d36a9f662a04e6982d33ea11bea373e8f)) 61 | * **gemfile.lock:** add to repo with updated `Gemfile` [skip ci] ([b5a46b0](https://github.com/saltstack-formulas/vim-formula/commit/b5a46b03138fd7ac64be6428883a892a7a931a52)) 62 | * **gitlab-ci:** use GitLab CI as Travis CI replacement ([c8f7bd8](https://github.com/saltstack-formulas/vim-formula/commit/c8f7bd8d4afaaba9214158c966ef4696054b7471)) 63 | * **kitchen:** avoid using bootstrap for `master` instances [skip ci] ([3fef519](https://github.com/saltstack-formulas/vim-formula/commit/3fef519fc127c4b099d80b2a1c9f207938de3803)) 64 | * **kitchen:** use `debian-10-master-py3` instead of `develop` [skip ci] ([1a55295](https://github.com/saltstack-formulas/vim-formula/commit/1a5529539c6a112d7587908ea485b43d2ae3c1a5)) 65 | * **kitchen:** use `develop` image until `master` is ready (`amazonlinux`) [skip ci] ([0b14160](https://github.com/saltstack-formulas/vim-formula/commit/0b14160ba190016b0acfa92283ac3d9816cd7132)) 66 | * **kitchen:** use `saltimages` Docker Hub where available [skip ci] ([e6b4532](https://github.com/saltstack-formulas/vim-formula/commit/e6b45323f001cc7c21351663e5d120ebafcd19d2)) 67 | * **kitchen+travis:** remove `master-py2-arch-base-latest` [skip ci] ([8e1157b](https://github.com/saltstack-formulas/vim-formula/commit/8e1157b49d521c0eaa1fd26c7a5ec84b65d7da99)) 68 | * **kitchen+travis:** upgrade matrix after `2019.2.2` release [skip ci] ([fe49f47](https://github.com/saltstack-formulas/vim-formula/commit/fe49f47f576e5f83b48a5c29a89961d59d65d3ea)) 69 | * **pre-commit:** add to formula [skip ci] ([281ff3c](https://github.com/saltstack-formulas/vim-formula/commit/281ff3c6930c4a29ff3c9fa5fdd2aebbdbf86d73)) 70 | * **pre-commit:** enable/disable `rstcheck` as relevant [skip ci] ([9a7c084](https://github.com/saltstack-formulas/vim-formula/commit/9a7c08450b9dcddcc0d198fa78bde8b01c5469e0)) 71 | * **pre-commit:** finalise `rstcheck` configuration [skip ci] ([b2d06e6](https://github.com/saltstack-formulas/vim-formula/commit/b2d06e66fc85882d44d3d18fd3f953317e4833e0)) 72 | * **travis:** add notifications => zulip [skip ci] ([23d89b1](https://github.com/saltstack-formulas/vim-formula/commit/23d89b1c86c41913941316b948f459d3b05863b4)) 73 | * **travis:** apply changes from build config validation [skip ci] ([f597621](https://github.com/saltstack-formulas/vim-formula/commit/f597621713cc173ac9c17bf532e116ecd7c5d3cc)) 74 | * **travis:** opt-in to `dpl v2` to complete build config validation [skip ci] ([36b9fed](https://github.com/saltstack-formulas/vim-formula/commit/36b9feda7c756c66c5304c3b0eafc1db8dfaa8c2)) 75 | * **travis:** quote pathspecs used with `git ls-files` [skip ci] ([a7848ce](https://github.com/saltstack-formulas/vim-formula/commit/a7848ce00106d8ab1672fe5aa55c0090e1bf5d3f)) 76 | * **travis:** run `shellcheck` during lint job [skip ci] ([7b7505e](https://github.com/saltstack-formulas/vim-formula/commit/7b7505e86c420bd1a96186c546cfdc5c4542e7bf)) 77 | * **travis:** update `salt-lint` config for `v0.0.10` [skip ci] ([3ed24f3](https://github.com/saltstack-formulas/vim-formula/commit/3ed24f3dad0897bd37b8bf29c1f3c01d32a57a55)) 78 | * **travis:** use `major.minor` for `semantic-release` version [skip ci] ([ba2083f](https://github.com/saltstack-formulas/vim-formula/commit/ba2083f74786bf617db263ca4c68938920184d2a)) 79 | * **travis:** use build config validation (beta) [skip ci] ([e262e3e](https://github.com/saltstack-formulas/vim-formula/commit/e262e3e7c849d424be3d0c23bde598bf8691151c)) 80 | * **workflows/commitlint:** add to repo [skip ci] ([d5e07a7](https://github.com/saltstack-formulas/vim-formula/commit/d5e07a762270a645704710bfde563e470802742e)) 81 | 82 | 83 | ### Documentation 84 | 85 | * **contributing:** remove to use org-level file instead [skip ci] ([2343c4f](https://github.com/saltstack-formulas/vim-formula/commit/2343c4fba4a26b23841cf546f25b54caf4b766d8)) 86 | * **readme:** update link to `CONTRIBUTING` [skip ci] ([8b9588e](https://github.com/saltstack-formulas/vim-formula/commit/8b9588e6b9bb99cb42d3eda9b8fe200791feade6)) 87 | 88 | 89 | ### Performance Improvements 90 | 91 | * **travis:** improve `salt-lint` invocation [skip ci] ([bc7efe4](https://github.com/saltstack-formulas/vim-formula/commit/bc7efe46262a8b7e053f65e042f26ad18850632d)) 92 | 93 | ## [0.15.2](https://github.com/saltstack-formulas/vim-formula/compare/v0.15.1...v0.15.2) (2019-10-11) 94 | 95 | 96 | ### Bug Fixes 97 | 98 | * **rubocop:** add fixes using `rubocop --safe-auto-correct` ([](https://github.com/saltstack-formulas/vim-formula/commit/48da97d)) 99 | 100 | 101 | ### Continuous Integration 102 | 103 | * **kitchen:** change `log_level` to `debug` instead of `info` ([](https://github.com/saltstack-formulas/vim-formula/commit/87d3cef)) 104 | * **kitchen:** install required packages to bootstrapped `opensuse` [skip ci] ([](https://github.com/saltstack-formulas/vim-formula/commit/ec79a33)) 105 | * **kitchen:** use bootstrapped `opensuse` images until `2019.2.2` [skip ci] ([](https://github.com/saltstack-formulas/vim-formula/commit/f2b0a59)) 106 | * **platform:** add `arch-base-latest` (commented out for now) [skip ci] ([](https://github.com/saltstack-formulas/vim-formula/commit/9e1b239)) 107 | * merge travis matrix, add `salt-lint` & `rubocop` to `lint` job ([](https://github.com/saltstack-formulas/vim-formula/commit/1098f97)) 108 | * merge travis matrix, add `salt-lint` & `rubocop` to `lint` job ([](https://github.com/saltstack-formulas/vim-formula/commit/4a0e7ae)) 109 | * **travis:** merge `rubocop` linter into main `lint` job ([](https://github.com/saltstack-formulas/vim-formula/commit/d53f277)) 110 | 111 | ## [0.15.1](https://github.com/saltstack-formulas/vim-formula/compare/v0.15.0...v0.15.1) (2019-09-23) 112 | 113 | 114 | ### Bug Fixes 115 | 116 | * **editor:** fix python3 compatibility ([5da26b6](https://github.com/saltstack-formulas/vim-formula/commit/5da26b6)) 117 | 118 | 119 | ### Continuous Integration 120 | 121 | * use `dist: bionic` & apply `opensuse-leap-15` SCP error workaround ([f9a3ef2](https://github.com/saltstack-formulas/vim-formula/commit/f9a3ef2)) 122 | * **yamllint:** add rule `empty-values` & use new `yaml-files` setting ([f5e8b84](https://github.com/saltstack-formulas/vim-formula/commit/f5e8b84)) 123 | 124 | # [0.15.0](https://github.com/saltstack-formulas/vim-formula/compare/v0.14.2...v0.15.0) (2019-09-06) 125 | 126 | 127 | ### Features 128 | 129 | * **semantic-release:** add semantic-release ([1894649](https://github.com/saltstack-formulas/vim-formula/commit/1894649)) 130 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes.vim: -------------------------------------------------------------------------------- 1 | " pyflakes.vim - A script to highlight Python code on the fly with warnings 2 | " from Pyflakes, a Python lint tool. 3 | " 4 | " Place this script and the accompanying pyflakes directory in 5 | " .vim/ftplugin/python. 6 | " 7 | " See README for additional installation and information. 8 | " 9 | " Thanks to matlib.vim for ideas/code on interactive linting. 10 | " 11 | " Maintainer: Kevin Watters 12 | " Version: 0.1 13 | 14 | if exists("b:did_pyflakes_plugin") 15 | finish " only load once 16 | else 17 | let b:did_pyflakes_plugin = 1 18 | endif 19 | 20 | if !exists('g:pyflakes_builtins') 21 | let g:pyflakes_builtins = [] 22 | endif 23 | 24 | if !exists("b:did_python_init") 25 | let b:did_python_init = 0 26 | 27 | if !has('python') 28 | echoerr "Error: the pyflakes.vim plugin requires Vim to be compiled with +python" 29 | finish 30 | endif 31 | 32 | if !exists('g:pyflakes_use_quickfix') 33 | let g:pyflakes_use_quickfix = 1 34 | endif 35 | 36 | 37 | python << EOF 38 | import vim 39 | import os.path 40 | import sys 41 | 42 | if sys.version_info[:2] < (2, 5): 43 | raise AssertionError('Vim must be compiled with Python 2.5 or higher; you have ' + sys.version) 44 | 45 | # get the directory this script is in: the pyflakes python module should be installed there. 46 | scriptdir = os.path.join(os.path.dirname(vim.eval('expand("")')), 'pyflakes') 47 | sys.path.insert(0, scriptdir) 48 | 49 | import ast 50 | from pyflakes import checker, messages 51 | from operator import attrgetter 52 | import re 53 | 54 | class loc(object): 55 | def __init__(self, lineno, col=None): 56 | self.lineno = lineno 57 | self.col_offset = col 58 | 59 | class SyntaxError(messages.Message): 60 | message = 'could not compile: %s' 61 | def __init__(self, filename, lineno, col, message): 62 | messages.Message.__init__(self, filename, loc(lineno, col)) 63 | self.message_args = (message,) 64 | 65 | class blackhole(object): 66 | write = flush = lambda *a, **k: None 67 | 68 | def check(buffer): 69 | filename = buffer.name 70 | contents = buffer[:] 71 | 72 | # shebang usually found at the top of the file, followed by source code encoding marker. 73 | # assume everything else that follows is encoded in the encoding. 74 | encoding_found = False 75 | for n, line in enumerate(contents): 76 | if n >= 2: 77 | break 78 | elif re.match(r'#.*coding[:=]\s*([-\w.]+)', line): 79 | contents = ['']*(n+1) + contents[n+1:] 80 | break 81 | 82 | contents = '\n'.join(contents) + '\n' 83 | 84 | vimenc = vim.eval('&encoding') 85 | if vimenc: 86 | contents = contents.decode(vimenc) 87 | 88 | builtins = set(['__file__']) 89 | try: 90 | builtins.update(set(eval(vim.eval('string(g:pyflakes_builtins)')))) 91 | except Exception: 92 | pass 93 | 94 | try: 95 | # TODO: use warnings filters instead of ignoring stderr 96 | old_stderr, sys.stderr = sys.stderr, blackhole() 97 | try: 98 | tree = ast.parse(contents, filename or '') 99 | finally: 100 | sys.stderr = old_stderr 101 | except: 102 | try: 103 | value = sys.exc_info()[1] 104 | lineno, offset, line = value[1][1:] 105 | except IndexError: 106 | lineno, offset, line = 1, 0, '' 107 | if line and line.endswith("\n"): 108 | line = line[:-1] 109 | 110 | return [SyntaxError(filename, lineno, offset, str(value))] 111 | else: 112 | # pyflakes looks to _MAGIC_GLOBALS in checker.py to see which 113 | # UndefinedNames to ignore 114 | old_globals = getattr(checker,' _MAGIC_GLOBALS', []) 115 | checker._MAGIC_GLOBALS = set(old_globals) | builtins 116 | 117 | w = checker.Checker(tree, filename) 118 | 119 | checker._MAGIC_GLOBALS = old_globals 120 | 121 | w.messages.sort(key = attrgetter('lineno')) 122 | return w.messages 123 | 124 | 125 | def vim_quote(s): 126 | return s.replace("'", "''") 127 | EOF 128 | let b:did_python_init = 1 129 | endif 130 | 131 | if !b:did_python_init 132 | finish 133 | endif 134 | 135 | au BufLeave call s:ClearPyflakes() 136 | 137 | au BufEnter call s:RunPyflakes() 138 | au InsertLeave call s:RunPyflakes() 139 | au InsertEnter call s:RunPyflakes() 140 | au BufWritePost call s:RunPyflakes() 141 | 142 | au CursorHold call s:RunPyflakes() 143 | au CursorHoldI call s:RunPyflakes() 144 | 145 | au CursorHold call s:GetPyflakesMessage() 146 | au CursorMoved call s:GetPyflakesMessage() 147 | 148 | if !exists("*s:PyflakesUpdate") 149 | function s:PyflakesUpdate() 150 | silent call s:RunPyflakes() 151 | call s:GetPyflakesMessage() 152 | endfunction 153 | endif 154 | 155 | " Call this function in your .vimrc to update PyFlakes 156 | if !exists(":PyflakesUpdate") 157 | command PyflakesUpdate :call s:PyflakesUpdate() 158 | endif 159 | 160 | " Hook common text manipulation commands to update PyFlakes 161 | " TODO: is there a more general "text op" autocommand we could register 162 | " for here? 163 | noremap dd dd:PyflakesUpdate 164 | noremap dw dw:PyflakesUpdate 165 | noremap u u:PyflakesUpdate 166 | noremap :PyflakesUpdate 167 | 168 | " WideMsg() prints [long] message up to (&columns-1) length 169 | " guaranteed without "Press Enter" prompt. 170 | if !exists("*s:WideMsg") 171 | function s:WideMsg(msg) 172 | let x=&ruler | let y=&showcmd 173 | set noruler noshowcmd 174 | redraw 175 | echo strpart(a:msg, 0, &columns-1) 176 | let &ruler=x | let &showcmd=y 177 | endfun 178 | endif 179 | 180 | if !exists("*s:GetQuickFixStackCount") 181 | function s:GetQuickFixStackCount() 182 | let l:stack_count = 0 183 | try 184 | silent colder 9 185 | catch /E380:/ 186 | endtry 187 | 188 | try 189 | for i in range(9) 190 | silent cnewer 191 | let l:stack_count = l:stack_count + 1 192 | endfor 193 | catch /E381:/ 194 | return l:stack_count 195 | endtry 196 | endfunction 197 | endif 198 | 199 | if !exists("*s:ActivatePyflakesQuickFixWindow") 200 | function s:ActivatePyflakesQuickFixWindow() 201 | try 202 | silent colder 9 " go to the bottom of quickfix stack 203 | catch /E380:/ 204 | endtry 205 | 206 | if s:pyflakes_qf > 0 207 | try 208 | exe "silent cnewer " . s:pyflakes_qf 209 | catch /E381:/ 210 | echoerr "Could not activate Pyflakes Quickfix Window." 211 | endtry 212 | endif 213 | endfunction 214 | endif 215 | 216 | if !exists("*s:RunPyflakes") 217 | function s:RunPyflakes() 218 | highlight link PyFlakes SpellBad 219 | 220 | if exists("b:cleared") 221 | if b:cleared == 0 222 | silent call s:ClearPyflakes() 223 | let b:cleared = 1 224 | endif 225 | else 226 | let b:cleared = 1 227 | endif 228 | 229 | let b:matched = [] 230 | let b:matchedlines = {} 231 | 232 | let b:qf_list = [] 233 | let b:qf_window_count = -1 234 | 235 | python << EOF 236 | for w in check(vim.current.buffer): 237 | vim.command('let s:matchDict = {}') 238 | vim.command("let s:matchDict['lineNum'] = " + str(w.lineno)) 239 | vim.command("let s:matchDict['message'] = '%s'" % vim_quote(w.message % w.message_args)) 240 | vim.command("let b:matchedlines[" + str(w.lineno) + "] = s:matchDict") 241 | 242 | vim.command("let l:qf_item = {}") 243 | vim.command("let l:qf_item.bufnr = bufnr('%')") 244 | vim.command("let l:qf_item.filename = expand('%')") 245 | vim.command("let l:qf_item.lnum = %s" % str(w.lineno)) 246 | vim.command("let l:qf_item.text = '%s'" % vim_quote(w.message % w.message_args)) 247 | vim.command("let l:qf_item.type = 'E'") 248 | 249 | if getattr(w, 'col', None) is None or isinstance(w, SyntaxError): 250 | # without column information, just highlight the whole line 251 | # (minus the newline) 252 | vim.command(r"let s:mID = matchadd('PyFlakes', '\%" + str(w.lineno) + r"l\n\@!')") 253 | else: 254 | # with a column number, highlight the first keyword there 255 | vim.command(r"let s:mID = matchadd('PyFlakes', '^\%" + str(w.lineno) + r"l\_.\{-}\zs\k\+\k\@!\%>" + str(w.col) + r"c')") 256 | 257 | vim.command("let l:qf_item.vcol = 1") 258 | vim.command("let l:qf_item.col = %s" % str(w.col + 1)) 259 | 260 | vim.command("call add(b:matched, s:matchDict)") 261 | vim.command("call add(b:qf_list, l:qf_item)") 262 | EOF 263 | if g:pyflakes_use_quickfix == 1 264 | if exists("s:pyflakes_qf") 265 | " if pyflakes quickfix window is already created, reuse it 266 | call s:ActivatePyflakesQuickFixWindow() 267 | call setqflist(b:qf_list, 'r') 268 | else 269 | " one pyflakes quickfix window for all buffer 270 | call setqflist(b:qf_list, '') 271 | let s:pyflakes_qf = s:GetQuickFixStackCount() 272 | endif 273 | endif 274 | 275 | let b:cleared = 0 276 | endfunction 277 | end 278 | 279 | " keep track of whether or not we are showing a message 280 | let b:showing_message = 0 281 | 282 | if !exists("*s:GetPyflakesMessage") 283 | function s:GetPyflakesMessage() 284 | let s:cursorPos = getpos(".") 285 | 286 | " Bail if RunPyflakes hasn't been called yet. 287 | if !exists('b:matchedlines') 288 | return 289 | endif 290 | 291 | " if there's a message for the line the cursor is currently on, echo 292 | " it to the console 293 | if has_key(b:matchedlines, s:cursorPos[1]) 294 | let s:pyflakesMatch = get(b:matchedlines, s:cursorPos[1]) 295 | call s:WideMsg(s:pyflakesMatch['message']) 296 | let b:showing_message = 1 297 | return 298 | endif 299 | 300 | " otherwise, if we're showing a message, clear it 301 | if b:showing_message == 1 302 | echo 303 | let b:showing_message = 0 304 | endif 305 | endfunction 306 | endif 307 | 308 | if !exists('*s:ClearPyflakes') 309 | function s:ClearPyflakes() 310 | let s:matches = getmatches() 311 | for s:matchId in s:matches 312 | if s:matchId['group'] == 'PyFlakes' 313 | call matchdelete(s:matchId['id']) 314 | endif 315 | endfor 316 | let b:matched = [] 317 | let b:matchedlines = {} 318 | let b:cleared = 1 319 | endfunction 320 | endif 321 | 322 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /docs/CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | 2 | Changelog 3 | ========= 4 | 5 | `0.15.5 `_ (2021-10-27) 6 | -------------------------------------------------------------------------------------------------------- 7 | 8 | Bug Fixes 9 | ^^^^^^^^^ 10 | 11 | 12 | * **init:** remove duplicate ``template: jinja`` line (\ `f83bb1b `_\ ), closes `#52 `_ `#51 `_ 13 | 14 | Continuous Integration 15 | ^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | 18 | * **3003.1:** update inc. AlmaLinux, Rocky & ``rst-lint`` [skip ci] (\ `60bd7fa `_\ ) 19 | * **gemfile+lock:** use ``ssf`` customised ``inspec`` repo [skip ci] (\ `a411383 `_\ ) 20 | * **kitchen:** move ``provisioner`` block & update ``run_command`` [skip ci] (\ `0a671a7 `_\ ) 21 | * **kitchen+ci:** update with latest ``3003.2`` pre-salted images [skip ci] (\ `4bcede1 `_\ ) 22 | * **kitchen+ci:** update with latest CVE pre-salted images [skip ci] (\ `12f3254 `_\ ) 23 | * add ``arch-master`` to matrix and update ``.travis.yml`` [skip ci] (\ `a659899 `_\ ) 24 | * add Debian 11 Bullseye & update ``yamllint`` configuration [skip ci] (\ `305701d `_\ ) 25 | * **kitchen+ci:** use latest pre-salted images (after CVE) [skip ci] (\ `82c9074 `_\ ) 26 | * **kitchen+gitlab:** adjust matrix to add ``3003`` [skip ci] (\ `e4e58d4 `_\ ) 27 | * **kitchen+gitlab:** remove Ubuntu 16.04 & Fedora 32 (EOL) [skip ci] (\ `516042f `_\ ) 28 | 29 | Tests 30 | ^^^^^ 31 | 32 | 33 | * standardise use of ``share`` suite & ``_mapdata`` state [skip ci] (\ `90a3fdc `_\ ) 34 | 35 | `0.15.4 `_ (2021-03-01) 36 | -------------------------------------------------------------------------------------------------------- 37 | 38 | Bug Fixes 39 | ^^^^^^^^^ 40 | 41 | 42 | * **vim/init.sls:** fix full vim installation on suse (\ `bc5283f `_\ ) 43 | 44 | Continuous Integration 45 | ^^^^^^^^^^^^^^^^^^^^^^ 46 | 47 | 48 | * **commitlint:** ensure ``upstream/master`` uses main repo URL [skip ci] (\ `e67e88a `_\ ) 49 | * **gemfile+lock:** use ``ssf`` customised ``kitchen-docker`` repo [skip ci] (\ `0e62788 `_\ ) 50 | * **gitlab-ci:** add ``rubocop`` linter (with ``allow_failure``\ ) [skip ci] (\ `225875d `_\ ) 51 | * **kitchen+gitlab-ci:** use latest pre-salted images [skip ci] (\ `9b340fd `_\ ) 52 | * **pre-commit:** update hook for ``rubocop`` [skip ci] (\ `ae2b632 `_\ ) 53 | 54 | Tests 55 | ^^^^^ 56 | 57 | 58 | * **package_spec:** adjust to work across all platforms (\ `e969de0 `_\ ) 59 | 60 | `0.15.3 `_ (2020-12-16) 61 | -------------------------------------------------------------------------------------------------------- 62 | 63 | Bug Fixes 64 | ^^^^^^^^^ 65 | 66 | 67 | * **release.config.js:** use full commit hash in commit link [skip ci] (\ `9f512da `_\ ) 68 | 69 | Continuous Integration 70 | ^^^^^^^^^^^^^^^^^^^^^^ 71 | 72 | 73 | * **gemfile:** restrict ``train`` gem version until upstream fix [skip ci] (\ `01d3a15 `_\ ) 74 | * **gemfile.lock:** add to repo with updated ``Gemfile`` [skip ci] (\ `b5a46b0 `_\ ) 75 | * **gitlab-ci:** use GitLab CI as Travis CI replacement (\ `c8f7bd8 `_\ ) 76 | * **kitchen:** avoid using bootstrap for ``master`` instances [skip ci] (\ `3fef519 `_\ ) 77 | * **kitchen:** use ``debian-10-master-py3`` instead of ``develop`` [skip ci] (\ `1a55295 `_\ ) 78 | * **kitchen:** use ``develop`` image until ``master`` is ready (\ ``amazonlinux``\ ) [skip ci] (\ `0b14160 `_\ ) 79 | * **kitchen:** use ``saltimages`` Docker Hub where available [skip ci] (\ `e6b4532 `_\ ) 80 | * **kitchen+travis:** remove ``master-py2-arch-base-latest`` [skip ci] (\ `8e1157b `_\ ) 81 | * **kitchen+travis:** upgrade matrix after ``2019.2.2`` release [skip ci] (\ `fe49f47 `_\ ) 82 | * **pre-commit:** add to formula [skip ci] (\ `281ff3c `_\ ) 83 | * **pre-commit:** enable/disable ``rstcheck`` as relevant [skip ci] (\ `9a7c084 `_\ ) 84 | * **pre-commit:** finalise ``rstcheck`` configuration [skip ci] (\ `b2d06e6 `_\ ) 85 | * **travis:** add notifications => zulip [skip ci] (\ `23d89b1 `_\ ) 86 | * **travis:** apply changes from build config validation [skip ci] (\ `f597621 `_\ ) 87 | * **travis:** opt-in to ``dpl v2`` to complete build config validation [skip ci] (\ `36b9fed `_\ ) 88 | * **travis:** quote pathspecs used with ``git ls-files`` [skip ci] (\ `a7848ce `_\ ) 89 | * **travis:** run ``shellcheck`` during lint job [skip ci] (\ `7b7505e `_\ ) 90 | * **travis:** update ``salt-lint`` config for ``v0.0.10`` [skip ci] (\ `3ed24f3 `_\ ) 91 | * **travis:** use ``major.minor`` for ``semantic-release`` version [skip ci] (\ `ba2083f `_\ ) 92 | * **travis:** use build config validation (beta) [skip ci] (\ `e262e3e `_\ ) 93 | * **workflows/commitlint:** add to repo [skip ci] (\ `d5e07a7 `_\ ) 94 | 95 | Documentation 96 | ^^^^^^^^^^^^^ 97 | 98 | 99 | * **contributing:** remove to use org-level file instead [skip ci] (\ `2343c4f `_\ ) 100 | * **readme:** update link to ``CONTRIBUTING`` [skip ci] (\ `8b9588e `_\ ) 101 | 102 | Performance Improvements 103 | ^^^^^^^^^^^^^^^^^^^^^^^^ 104 | 105 | 106 | * **travis:** improve ``salt-lint`` invocation [skip ci] (\ `bc7efe4 `_\ ) 107 | 108 | `0.15.2 `_ (2019-10-11) 109 | -------------------------------------------------------------------------------------------------------- 110 | 111 | Bug Fixes 112 | ^^^^^^^^^ 113 | 114 | 115 | * **rubocop:** add fixes using ``rubocop --safe-auto-correct`` (\ ` `_\ ) 116 | 117 | Continuous Integration 118 | ^^^^^^^^^^^^^^^^^^^^^^ 119 | 120 | 121 | * **kitchen:** change ``log_level`` to ``debug`` instead of ``info`` (\ ` `_\ ) 122 | * **kitchen:** install required packages to bootstrapped ``opensuse`` [skip ci] (\ ` `_\ ) 123 | * **kitchen:** use bootstrapped ``opensuse`` images until ``2019.2.2`` [skip ci] (\ ` `_\ ) 124 | * **platform:** add ``arch-base-latest`` (commented out for now) [skip ci] (\ ` `_\ ) 125 | * merge travis matrix, add ``salt-lint`` & ``rubocop`` to ``lint`` job (\ ` `_\ ) 126 | * merge travis matrix, add ``salt-lint`` & ``rubocop`` to ``lint`` job (\ ` `_\ ) 127 | * **travis:** merge ``rubocop`` linter into main ``lint`` job (\ ` `_\ ) 128 | 129 | `0.15.1 `_ (2019-09-23) 130 | -------------------------------------------------------------------------------------------------------- 131 | 132 | Bug Fixes 133 | ^^^^^^^^^ 134 | 135 | 136 | * **editor:** fix python3 compatibility (\ `5da26b6 `_\ ) 137 | 138 | Continuous Integration 139 | ^^^^^^^^^^^^^^^^^^^^^^ 140 | 141 | 142 | * use ``dist: bionic`` & apply ``opensuse-leap-15`` SCP error workaround (\ `f9a3ef2 `_\ ) 143 | * **yamllint:** add rule ``empty-values`` & use new ``yaml-files`` setting (\ `f5e8b84 `_\ ) 144 | 145 | `0.15.0 `_ (2019-09-06) 146 | -------------------------------------------------------------------------------------------------------- 147 | 148 | Features 149 | ^^^^^^^^ 150 | 151 | 152 | * **semantic-release:** add semantic-release (\ `1894649 `_\ ) 153 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/pyflakes/test/test_other.py: -------------------------------------------------------------------------------- 1 | # (c) 2005-2010 Divmod, Inc. 2 | # See LICENSE file for details 3 | 4 | """ 5 | Tests for various Pyflakes behavior. 6 | """ 7 | 8 | from sys import version_info 9 | 10 | from pyflakes import messages as m 11 | from pyflakes.test import harness 12 | 13 | 14 | class Test(harness.Test): 15 | 16 | def test_duplicateArgs(self): 17 | self.flakes('def fu(bar, bar): pass', m.DuplicateArgument) 18 | 19 | def test_localReferencedBeforeAssignment(self): 20 | self.flakes(''' 21 | a = 1 22 | def f(): 23 | a; a=1 24 | f() 25 | ''', m.UndefinedName) 26 | test_localReferencedBeforeAssignment.todo = 'this requires finding all assignments in the function body first' 27 | 28 | def test_redefinedFunction(self): 29 | """ 30 | Test that shadowing a function definition with another one raises a 31 | warning. 32 | """ 33 | self.flakes(''' 34 | def a(): pass 35 | def a(): pass 36 | ''', m.RedefinedFunction) 37 | 38 | def test_redefinedClassFunction(self): 39 | """ 40 | Test that shadowing a function definition in a class suite with another 41 | one raises a warning. 42 | """ 43 | self.flakes(''' 44 | class A: 45 | def a(): pass 46 | def a(): pass 47 | ''', m.RedefinedFunction) 48 | 49 | def test_functionDecorator(self): 50 | """ 51 | Test that shadowing a function definition with a decorated version of 52 | that function does not raise a warning. 53 | """ 54 | self.flakes(''' 55 | from somewhere import somedecorator 56 | 57 | def a(): pass 58 | a = somedecorator(a) 59 | ''') 60 | 61 | def test_classFunctionDecorator(self): 62 | """ 63 | Test that shadowing a function definition in a class suite with a 64 | decorated version of that function does not raise a warning. 65 | """ 66 | self.flakes(''' 67 | class A: 68 | def a(): pass 69 | a = classmethod(a) 70 | ''') 71 | 72 | def test_unaryPlus(self): 73 | '''Don't die on unary +''' 74 | self.flakes('+1') 75 | 76 | 77 | def test_undefinedBaseClass(self): 78 | """ 79 | If a name in the base list of a class definition is undefined, a 80 | warning is emitted. 81 | """ 82 | self.flakes(''' 83 | class foo(foo): 84 | pass 85 | ''', m.UndefinedName) 86 | 87 | 88 | def test_classNameUndefinedInClassBody(self): 89 | """ 90 | If a class name is used in the body of that class's definition and 91 | the name is not already defined, a warning is emitted. 92 | """ 93 | self.flakes(''' 94 | class foo: 95 | foo 96 | ''', m.UndefinedName) 97 | 98 | 99 | def test_classNameDefinedPreviously(self): 100 | """ 101 | If a class name is used in the body of that class's definition and 102 | the name was previously defined in some other way, no warning is 103 | emitted. 104 | """ 105 | self.flakes(''' 106 | foo = None 107 | class foo: 108 | foo 109 | ''') 110 | 111 | 112 | def test_comparison(self): 113 | """ 114 | If a defined name is used on either side of any of the six comparison 115 | operators, no warning is emitted. 116 | """ 117 | self.flakes(''' 118 | x = 10 119 | y = 20 120 | x < y 121 | x <= y 122 | x == y 123 | x != y 124 | x >= y 125 | x > y 126 | ''') 127 | 128 | 129 | def test_identity(self): 130 | """ 131 | If a deefined name is used on either side of an identity test, no 132 | warning is emitted. 133 | """ 134 | self.flakes(''' 135 | x = 10 136 | y = 20 137 | x is y 138 | x is not y 139 | ''') 140 | 141 | 142 | def test_containment(self): 143 | """ 144 | If a defined name is used on either side of a containment test, no 145 | warning is emitted. 146 | """ 147 | self.flakes(''' 148 | x = 10 149 | y = 20 150 | x in y 151 | x not in y 152 | ''') 153 | 154 | 155 | def test_loopControl(self): 156 | """ 157 | break and continue statements are supported. 158 | """ 159 | self.flakes(''' 160 | for x in [1, 2]: 161 | break 162 | ''') 163 | self.flakes(''' 164 | for x in [1, 2]: 165 | continue 166 | ''') 167 | 168 | 169 | def test_ellipsis(self): 170 | """ 171 | Ellipsis in a slice is supported. 172 | """ 173 | self.flakes(''' 174 | [1, 2][...] 175 | ''') 176 | 177 | 178 | def test_extendedSlice(self): 179 | """ 180 | Extended slices are supported. 181 | """ 182 | self.flakes(''' 183 | x = 3 184 | [1, 2][x,:] 185 | ''') 186 | 187 | 188 | 189 | class TestUnusedAssignment(harness.Test): 190 | """ 191 | Tests for warning about unused assignments. 192 | """ 193 | 194 | def test_unusedVariable(self): 195 | """ 196 | Warn when a variable in a function is assigned a value that's never 197 | used. 198 | """ 199 | self.flakes(''' 200 | def a(): 201 | b = 1 202 | ''', m.UnusedVariable) 203 | 204 | 205 | def test_assignToGlobal(self): 206 | """ 207 | Assigning to a global and then not using that global is perfectly 208 | acceptable. Do not mistake it for an unused local variable. 209 | """ 210 | self.flakes(''' 211 | b = 0 212 | def a(): 213 | global b 214 | b = 1 215 | ''') 216 | 217 | 218 | def test_assignToMember(self): 219 | """ 220 | Assigning to a member of another object and then not using that member 221 | variable is perfectly acceptable. Do not mistake it for an unused 222 | local variable. 223 | """ 224 | # XXX: Adding this test didn't generate a failure. Maybe not 225 | # necessary? 226 | self.flakes(''' 227 | class b: 228 | pass 229 | def a(): 230 | b.foo = 1 231 | ''') 232 | 233 | 234 | def test_assignInForLoop(self): 235 | """ 236 | Don't warn when a variable in a for loop is assigned to but not used. 237 | """ 238 | self.flakes(''' 239 | def f(): 240 | for i in range(10): 241 | pass 242 | ''') 243 | 244 | 245 | def test_assignInListComprehension(self): 246 | """ 247 | Don't warn when a variable in a list comprehension is assigned to but 248 | not used. 249 | """ 250 | self.flakes(''' 251 | def f(): 252 | [None for i in range(10)] 253 | ''') 254 | 255 | 256 | def test_generatorExpression(self): 257 | """ 258 | Don't warn when a variable in a generator expression is assigned to but not used. 259 | """ 260 | self.flakes(''' 261 | def f(): 262 | (None for i in range(10)) 263 | ''') 264 | 265 | 266 | def test_assignmentInsideLoop(self): 267 | """ 268 | Don't warn when a variable assignment occurs lexically after its use. 269 | """ 270 | self.flakes(''' 271 | def f(): 272 | x = None 273 | for i in range(10): 274 | if i > 2: 275 | return x 276 | x = i * 2 277 | ''') 278 | 279 | 280 | def test_tupleUnpacking(self): 281 | """ 282 | Don't warn when a variable included in tuple unpacking is unused. It's 283 | very common for variables in a tuple unpacking assignment to be unused 284 | in good Python code, so warning will only create false positives. 285 | """ 286 | self.flakes(''' 287 | def f(): 288 | (x, y) = 1, 2 289 | ''') 290 | 291 | 292 | def test_listUnpacking(self): 293 | """ 294 | Don't warn when a variable included in list unpacking is unused. 295 | """ 296 | self.flakes(''' 297 | def f(): 298 | [x, y] = [1, 2] 299 | ''') 300 | 301 | 302 | def test_closedOver(self): 303 | """ 304 | Don't warn when the assignment is used in an inner function. 305 | """ 306 | self.flakes(''' 307 | def barMaker(): 308 | foo = 5 309 | def bar(): 310 | return foo 311 | return bar 312 | ''') 313 | 314 | 315 | def test_doubleClosedOver(self): 316 | """ 317 | Don't warn when the assignment is used in an inner function, even if 318 | that inner function itself is in an inner function. 319 | """ 320 | self.flakes(''' 321 | def barMaker(): 322 | foo = 5 323 | def bar(): 324 | def baz(): 325 | return foo 326 | return bar 327 | ''') 328 | 329 | 330 | 331 | class Python25Test(harness.Test): 332 | """ 333 | Tests for checking of syntax only available in Python 2.5 and newer. 334 | """ 335 | if version_info < (2, 5): 336 | skip = "Python 2.5 required for if-else and with tests" 337 | 338 | def test_ifexp(self): 339 | """ 340 | Test C{foo if bar else baz} statements. 341 | """ 342 | self.flakes("a = 'moo' if True else 'oink'") 343 | self.flakes("a = foo if True else 'oink'", m.UndefinedName) 344 | self.flakes("a = 'moo' if True else bar", m.UndefinedName) 345 | 346 | 347 | def test_withStatementNoNames(self): 348 | """ 349 | No warnings are emitted for using inside or after a nameless C{with} 350 | statement a name defined beforehand. 351 | """ 352 | self.flakes(''' 353 | from __future__ import with_statement 354 | bar = None 355 | with open("foo"): 356 | bar 357 | bar 358 | ''') 359 | 360 | def test_withStatementSingleName(self): 361 | """ 362 | No warnings are emitted for using a name defined by a C{with} statement 363 | within the suite or afterwards. 364 | """ 365 | self.flakes(''' 366 | from __future__ import with_statement 367 | with open('foo') as bar: 368 | bar 369 | bar 370 | ''') 371 | 372 | 373 | def test_withStatementAttributeName(self): 374 | """ 375 | No warnings are emitted for using an attribute as the target of a 376 | C{with} statement. 377 | """ 378 | self.flakes(''' 379 | from __future__ import with_statement 380 | import foo 381 | with open('foo') as foo.bar: 382 | pass 383 | ''') 384 | 385 | 386 | def test_withStatementSubscript(self): 387 | """ 388 | No warnings are emitted for using a subscript as the target of a 389 | C{with} statement. 390 | """ 391 | self.flakes(''' 392 | from __future__ import with_statement 393 | import foo 394 | with open('foo') as foo[0]: 395 | pass 396 | ''') 397 | 398 | 399 | def test_withStatementSubscriptUndefined(self): 400 | """ 401 | An undefined name warning is emitted if the subscript used as the 402 | target of a C{with} statement is not defined. 403 | """ 404 | self.flakes(''' 405 | from __future__ import with_statement 406 | import foo 407 | with open('foo') as foo[bar]: 408 | pass 409 | ''', m.UndefinedName) 410 | 411 | 412 | def test_withStatementTupleNames(self): 413 | """ 414 | No warnings are emitted for using any of the tuple of names defined by 415 | a C{with} statement within the suite or afterwards. 416 | """ 417 | self.flakes(''' 418 | from __future__ import with_statement 419 | with open('foo') as (bar, baz): 420 | bar, baz 421 | bar, baz 422 | ''') 423 | 424 | 425 | def test_withStatementListNames(self): 426 | """ 427 | No warnings are emitted for using any of the list of names defined by a 428 | C{with} statement within the suite or afterwards. 429 | """ 430 | self.flakes(''' 431 | from __future__ import with_statement 432 | with open('foo') as [bar, baz]: 433 | bar, baz 434 | bar, baz 435 | ''') 436 | 437 | 438 | def test_withStatementComplicatedTarget(self): 439 | """ 440 | If the target of a C{with} statement uses any or all of the valid forms 441 | for that part of the grammar (See 442 | U{http://docs.python.org/reference/compound_stmts.html#the-with-statement}), 443 | the names involved are checked both for definedness and any bindings 444 | created are respected in the suite of the statement and afterwards. 445 | """ 446 | self.flakes(''' 447 | from __future__ import with_statement 448 | c = d = e = g = h = i = None 449 | with open('foo') as [(a, b), c[d], e.f, g[h:i]]: 450 | a, b, c, d, e, g, h, i 451 | a, b, c, d, e, g, h, i 452 | ''') 453 | 454 | 455 | def test_withStatementSingleNameUndefined(self): 456 | """ 457 | An undefined name warning is emitted if the name first defined by a 458 | C{with} statement is used before the C{with} statement. 459 | """ 460 | self.flakes(''' 461 | from __future__ import with_statement 462 | bar 463 | with open('foo') as bar: 464 | pass 465 | ''', m.UndefinedName) 466 | 467 | 468 | def test_withStatementTupleNamesUndefined(self): 469 | """ 470 | An undefined name warning is emitted if a name first defined by a the 471 | tuple-unpacking form of the C{with} statement is used before the 472 | C{with} statement. 473 | """ 474 | self.flakes(''' 475 | from __future__ import with_statement 476 | baz 477 | with open('foo') as (bar, baz): 478 | pass 479 | ''', m.UndefinedName) 480 | 481 | 482 | def test_withStatementSingleNameRedefined(self): 483 | """ 484 | A redefined name warning is emitted if a name bound by an import is 485 | rebound by the name defined by a C{with} statement. 486 | """ 487 | self.flakes(''' 488 | from __future__ import with_statement 489 | import bar 490 | with open('foo') as bar: 491 | pass 492 | ''', m.RedefinedWhileUnused) 493 | 494 | 495 | def test_withStatementTupleNamesRedefined(self): 496 | """ 497 | A redefined name warning is emitted if a name bound by an import is 498 | rebound by one of the names defined by the tuple-unpacking form of a 499 | C{with} statement. 500 | """ 501 | self.flakes(''' 502 | from __future__ import with_statement 503 | import bar 504 | with open('foo') as (bar, baz): 505 | pass 506 | ''', m.RedefinedWhileUnused) 507 | 508 | 509 | def test_withStatementUndefinedInside(self): 510 | """ 511 | An undefined name warning is emitted if a name is used inside the 512 | body of a C{with} statement without first being bound. 513 | """ 514 | self.flakes(''' 515 | from __future__ import with_statement 516 | with open('foo') as bar: 517 | baz 518 | ''', m.UndefinedName) 519 | 520 | 521 | def test_withStatementNameDefinedInBody(self): 522 | """ 523 | A name defined in the body of a C{with} statement can be used after 524 | the body ends without warning. 525 | """ 526 | self.flakes(''' 527 | from __future__ import with_statement 528 | with open('foo') as bar: 529 | baz = 10 530 | baz 531 | ''') 532 | 533 | 534 | def test_withStatementUndefinedInExpression(self): 535 | """ 536 | An undefined name warning is emitted if a name in the I{test} 537 | expression of a C{with} statement is undefined. 538 | """ 539 | self.flakes(''' 540 | from __future__ import with_statement 541 | with bar as baz: 542 | pass 543 | ''', m.UndefinedName) 544 | 545 | self.flakes(''' 546 | from __future__ import with_statement 547 | with bar as bar: 548 | pass 549 | ''', m.UndefinedName) 550 | 551 | 552 | 553 | class Python27Test(harness.Test): 554 | """ 555 | Tests for checking of syntax only available in Python 2.7 and newer. 556 | """ 557 | if version_info < (2, 7): 558 | skip = "Python 2.7 required for dict/set comprehension tests" 559 | 560 | def test_dictComprehension(self): 561 | """ 562 | Dict comprehensions are properly handled. 563 | """ 564 | self.flakes(''' 565 | a = {1: x for x in range(10)} 566 | ''') 567 | 568 | def test_setComprehensionAndLiteral(self): 569 | """ 570 | Set comprehensions are properly handled. 571 | """ 572 | self.flakes(''' 573 | a = {1, 2, 3} 574 | b = {x for x in range(10)} 575 | ''') 576 | -------------------------------------------------------------------------------- /vim/files/pyflakes/ftplugin/python/pyflakes/pyflakes/test/test_imports.py: -------------------------------------------------------------------------------- 1 | 2 | from sys import version_info 3 | 4 | from pyflakes import messages as m 5 | from pyflakes.test import harness 6 | 7 | class Test(harness.Test): 8 | 9 | def test_unusedImport(self): 10 | self.flakes('import fu, bar', m.UnusedImport, m.UnusedImport) 11 | self.flakes('from baz import fu, bar', m.UnusedImport, m.UnusedImport) 12 | 13 | def test_aliasedImport(self): 14 | self.flakes('import fu as FU, bar as FU', m.RedefinedWhileUnused, m.UnusedImport) 15 | self.flakes('from moo import fu as FU, bar as FU', m.RedefinedWhileUnused, m.UnusedImport) 16 | 17 | def test_usedImport(self): 18 | self.flakes('import fu; print fu') 19 | self.flakes('from baz import fu; print fu') 20 | 21 | def test_redefinedWhileUnused(self): 22 | self.flakes('import fu; fu = 3', m.RedefinedWhileUnused) 23 | self.flakes('import fu; del fu', m.RedefinedWhileUnused) 24 | self.flakes('import fu; fu, bar = 3', m.RedefinedWhileUnused) 25 | self.flakes('import fu; [fu, bar] = 3', m.RedefinedWhileUnused) 26 | 27 | def test_redefinedByFunction(self): 28 | self.flakes(''' 29 | import fu 30 | def fu(): 31 | pass 32 | ''', m.RedefinedWhileUnused) 33 | 34 | def test_redefinedInNestedFunction(self): 35 | """ 36 | Test that shadowing a global name with a nested function definition 37 | generates a warning. 38 | """ 39 | self.flakes(''' 40 | import fu 41 | def bar(): 42 | def baz(): 43 | def fu(): 44 | pass 45 | ''', m.RedefinedWhileUnused, m.UnusedImport) 46 | 47 | def test_redefinedByClass(self): 48 | self.flakes(''' 49 | import fu 50 | class fu: 51 | pass 52 | ''', m.RedefinedWhileUnused) 53 | 54 | 55 | def test_redefinedBySubclass(self): 56 | """ 57 | If an imported name is redefined by a class statement which also uses 58 | that name in the bases list, no warning is emitted. 59 | """ 60 | self.flakes(''' 61 | from fu import bar 62 | class bar(bar): 63 | pass 64 | ''') 65 | 66 | 67 | def test_redefinedInClass(self): 68 | """ 69 | Test that shadowing a global with a class attribute does not produce a 70 | warning. 71 | """ 72 | self.flakes(''' 73 | import fu 74 | class bar: 75 | fu = 1 76 | print fu 77 | ''') 78 | 79 | def test_usedInFunction(self): 80 | self.flakes(''' 81 | import fu 82 | def fun(): 83 | print fu 84 | ''') 85 | 86 | def test_shadowedByParameter(self): 87 | self.flakes(''' 88 | import fu 89 | def fun(fu): 90 | print fu 91 | ''', m.UnusedImport) 92 | 93 | self.flakes(''' 94 | import fu 95 | def fun(fu): 96 | print fu 97 | print fu 98 | ''') 99 | 100 | def test_newAssignment(self): 101 | self.flakes('fu = None') 102 | 103 | def test_usedInGetattr(self): 104 | self.flakes('import fu; fu.bar.baz') 105 | self.flakes('import fu; "bar".fu.baz', m.UnusedImport) 106 | 107 | def test_usedInSlice(self): 108 | self.flakes('import fu; print fu.bar[1:]') 109 | 110 | def test_usedInIfBody(self): 111 | self.flakes(''' 112 | import fu 113 | if True: print fu 114 | ''') 115 | 116 | def test_usedInIfConditional(self): 117 | self.flakes(''' 118 | import fu 119 | if fu: pass 120 | ''') 121 | 122 | def test_usedInElifConditional(self): 123 | self.flakes(''' 124 | import fu 125 | if False: pass 126 | elif fu: pass 127 | ''') 128 | 129 | def test_usedInElse(self): 130 | self.flakes(''' 131 | import fu 132 | if False: pass 133 | else: print fu 134 | ''') 135 | 136 | def test_usedInCall(self): 137 | self.flakes('import fu; fu.bar()') 138 | 139 | def test_usedInClass(self): 140 | self.flakes(''' 141 | import fu 142 | class bar: 143 | bar = fu 144 | ''') 145 | 146 | def test_usedInClassBase(self): 147 | self.flakes(''' 148 | import fu 149 | class bar(object, fu.baz): 150 | pass 151 | ''') 152 | 153 | def test_notUsedInNestedScope(self): 154 | self.flakes(''' 155 | import fu 156 | def bleh(): 157 | pass 158 | print fu 159 | ''') 160 | 161 | def test_usedInFor(self): 162 | self.flakes(''' 163 | import fu 164 | for bar in range(9): 165 | print fu 166 | ''') 167 | 168 | def test_usedInForElse(self): 169 | self.flakes(''' 170 | import fu 171 | for bar in range(10): 172 | pass 173 | else: 174 | print fu 175 | ''') 176 | 177 | def test_redefinedByFor(self): 178 | self.flakes(''' 179 | import fu 180 | for fu in range(2): 181 | pass 182 | ''', m.RedefinedWhileUnused) 183 | 184 | def test_shadowedByFor(self): 185 | """ 186 | Test that shadowing a global name with a for loop variable generates a 187 | warning. 188 | """ 189 | self.flakes(''' 190 | import fu 191 | fu.bar() 192 | for fu in (): 193 | pass 194 | ''', m.ImportShadowedByLoopVar) 195 | 196 | def test_shadowedByForDeep(self): 197 | """ 198 | Test that shadowing a global name with a for loop variable nested in a 199 | tuple unpack generates a warning. 200 | """ 201 | self.flakes(''' 202 | import fu 203 | fu.bar() 204 | for (x, y, z, (a, b, c, (fu,))) in (): 205 | pass 206 | ''', m.ImportShadowedByLoopVar) 207 | 208 | def test_usedInReturn(self): 209 | self.flakes(''' 210 | import fu 211 | def fun(): 212 | return fu 213 | ''') 214 | 215 | def test_usedInOperators(self): 216 | self.flakes('import fu; 3 + fu.bar') 217 | self.flakes('import fu; 3 % fu.bar') 218 | self.flakes('import fu; 3 - fu.bar') 219 | self.flakes('import fu; 3 * fu.bar') 220 | self.flakes('import fu; 3 ** fu.bar') 221 | self.flakes('import fu; 3 / fu.bar') 222 | self.flakes('import fu; 3 // fu.bar') 223 | self.flakes('import fu; -fu.bar') 224 | self.flakes('import fu; ~fu.bar') 225 | self.flakes('import fu; 1 == fu.bar') 226 | self.flakes('import fu; 1 | fu.bar') 227 | self.flakes('import fu; 1 & fu.bar') 228 | self.flakes('import fu; 1 ^ fu.bar') 229 | self.flakes('import fu; 1 >> fu.bar') 230 | self.flakes('import fu; 1 << fu.bar') 231 | 232 | def test_usedInAssert(self): 233 | self.flakes('import fu; assert fu.bar') 234 | 235 | def test_usedInSubscript(self): 236 | self.flakes('import fu; fu.bar[1]') 237 | 238 | def test_usedInLogic(self): 239 | self.flakes('import fu; fu and False') 240 | self.flakes('import fu; fu or False') 241 | self.flakes('import fu; not fu.bar') 242 | 243 | def test_usedInList(self): 244 | self.flakes('import fu; [fu]') 245 | 246 | def test_usedInTuple(self): 247 | self.flakes('import fu; (fu,)') 248 | 249 | def test_usedInTry(self): 250 | self.flakes(''' 251 | import fu 252 | try: fu 253 | except: pass 254 | ''') 255 | 256 | def test_usedInExcept(self): 257 | self.flakes(''' 258 | import fu 259 | try: fu 260 | except: pass 261 | ''') 262 | 263 | def test_redefinedByExcept(self): 264 | self.flakes(''' 265 | import fu 266 | try: pass 267 | except Exception, fu: pass 268 | ''', m.RedefinedWhileUnused) 269 | 270 | def test_usedInRaise(self): 271 | self.flakes(''' 272 | import fu 273 | raise fu.bar 274 | ''') 275 | 276 | def test_usedInYield(self): 277 | self.flakes(''' 278 | import fu 279 | def gen(): 280 | yield fu 281 | ''') 282 | 283 | def test_usedInDict(self): 284 | self.flakes('import fu; {fu:None}') 285 | self.flakes('import fu; {1:fu}') 286 | 287 | def test_usedInParameterDefault(self): 288 | self.flakes(''' 289 | import fu 290 | def f(bar=fu): 291 | pass 292 | ''') 293 | 294 | def test_usedInAttributeAssign(self): 295 | self.flakes('import fu; fu.bar = 1') 296 | 297 | def test_usedInKeywordArg(self): 298 | self.flakes('import fu; fu.bar(stuff=fu)') 299 | 300 | def test_usedInAssignment(self): 301 | self.flakes('import fu; bar=fu') 302 | self.flakes('import fu; n=0; n+=fu') 303 | 304 | def test_usedInListComp(self): 305 | self.flakes('import fu; [fu for _ in range(1)]') 306 | self.flakes('import fu; [1 for _ in range(1) if fu]') 307 | 308 | def test_redefinedByListComp(self): 309 | self.flakes('import fu; [1 for fu in range(1)]', m.RedefinedWhileUnused) 310 | 311 | 312 | def test_usedInTryFinally(self): 313 | self.flakes(''' 314 | import fu 315 | try: pass 316 | finally: fu 317 | ''') 318 | 319 | self.flakes(''' 320 | import fu 321 | try: fu 322 | finally: pass 323 | ''') 324 | 325 | def test_usedInWhile(self): 326 | self.flakes(''' 327 | import fu 328 | while 0: 329 | fu 330 | ''') 331 | 332 | self.flakes(''' 333 | import fu 334 | while fu: pass 335 | ''') 336 | 337 | def test_usedInGlobal(self): 338 | self.flakes(''' 339 | import fu 340 | def f(): global fu 341 | ''', m.UnusedImport) 342 | 343 | def test_usedInBackquote(self): 344 | self.flakes('import fu; `fu`') 345 | 346 | def test_usedInExec(self): 347 | self.flakes('import fu; exec "print 1" in fu.bar') 348 | 349 | def test_usedInLambda(self): 350 | self.flakes('import fu; lambda: fu') 351 | 352 | def test_shadowedByLambda(self): 353 | self.flakes('import fu; lambda fu: fu', m.UnusedImport) 354 | 355 | def test_usedInSliceObj(self): 356 | self.flakes('import fu; "meow"[::fu]') 357 | 358 | def test_unusedInNestedScope(self): 359 | self.flakes(''' 360 | def bar(): 361 | import fu 362 | fu 363 | ''', m.UnusedImport, m.UndefinedName) 364 | 365 | def test_methodsDontUseClassScope(self): 366 | self.flakes(''' 367 | class bar: 368 | import fu 369 | def fun(self): 370 | fu 371 | ''', m.UnusedImport, m.UndefinedName) 372 | 373 | def test_nestedFunctionsNestScope(self): 374 | self.flakes(''' 375 | def a(): 376 | def b(): 377 | fu 378 | import fu 379 | ''') 380 | 381 | def test_nestedClassAndFunctionScope(self): 382 | self.flakes(''' 383 | def a(): 384 | import fu 385 | class b: 386 | def c(self): 387 | print fu 388 | ''') 389 | 390 | def test_importStar(self): 391 | self.flakes('from fu import *', m.ImportStarUsed) 392 | 393 | 394 | def test_packageImport(self): 395 | """ 396 | If a dotted name is imported and used, no warning is reported. 397 | """ 398 | self.flakes(''' 399 | import fu.bar 400 | fu.bar 401 | ''') 402 | 403 | 404 | def test_unusedPackageImport(self): 405 | """ 406 | If a dotted name is imported and not used, an unused import warning is 407 | reported. 408 | """ 409 | self.flakes('import fu.bar', m.UnusedImport) 410 | 411 | 412 | def test_duplicateSubmoduleImport(self): 413 | """ 414 | If a submodule of a package is imported twice, an unused import warning 415 | and a redefined while unused warning are reported. 416 | """ 417 | self.flakes(''' 418 | import fu.bar, fu.bar 419 | fu.bar 420 | ''', m.RedefinedWhileUnused) 421 | self.flakes(''' 422 | import fu.bar 423 | import fu.bar 424 | fu.bar 425 | ''', m.RedefinedWhileUnused) 426 | 427 | 428 | def test_differentSubmoduleImport(self): 429 | """ 430 | If two different submodules of a package are imported, no duplicate 431 | import warning is reported for the package. 432 | """ 433 | self.flakes(''' 434 | import fu.bar, fu.baz 435 | fu.bar, fu.baz 436 | ''') 437 | self.flakes(''' 438 | import fu.bar 439 | import fu.baz 440 | fu.bar, fu.baz 441 | ''') 442 | 443 | def test_assignRHSFirst(self): 444 | self.flakes('import fu; fu = fu') 445 | self.flakes('import fu; fu, bar = fu') 446 | self.flakes('import fu; [fu, bar] = fu') 447 | self.flakes('import fu; fu += fu') 448 | 449 | def test_tryingMultipleImports(self): 450 | self.flakes(''' 451 | try: 452 | import fu 453 | except ImportError: 454 | import bar as fu 455 | ''') 456 | test_tryingMultipleImports.todo = '' 457 | 458 | def test_nonGlobalDoesNotRedefine(self): 459 | self.flakes(''' 460 | import fu 461 | def a(): 462 | fu = 3 463 | return fu 464 | fu 465 | ''') 466 | 467 | def test_functionsRunLater(self): 468 | self.flakes(''' 469 | def a(): 470 | fu 471 | import fu 472 | ''') 473 | 474 | def test_functionNamesAreBoundNow(self): 475 | self.flakes(''' 476 | import fu 477 | def fu(): 478 | fu 479 | fu 480 | ''', m.RedefinedWhileUnused) 481 | 482 | def test_ignoreNonImportRedefinitions(self): 483 | self.flakes('a = 1; a = 2') 484 | 485 | def test_importingForImportError(self): 486 | self.flakes(''' 487 | try: 488 | import fu 489 | except ImportError: 490 | pass 491 | ''') 492 | test_importingForImportError.todo = '' 493 | 494 | def test_importedInClass(self): 495 | '''Imports in class scope can be used through self''' 496 | self.flakes(''' 497 | class c: 498 | import i 499 | def __init__(self): 500 | self.i 501 | ''') 502 | test_importedInClass.todo = 'requires evaluating attribute access' 503 | 504 | def test_futureImport(self): 505 | '''__future__ is special''' 506 | self.flakes('from __future__ import division') 507 | self.flakes(''' 508 | "docstring is allowed before future import" 509 | from __future__ import division 510 | ''') 511 | 512 | def test_futureImportFirst(self): 513 | """ 514 | __future__ imports must come before anything else. 515 | """ 516 | self.flakes(''' 517 | x = 5 518 | from __future__ import division 519 | ''', m.LateFutureImport) 520 | self.flakes(''' 521 | from foo import bar 522 | from __future__ import division 523 | bar 524 | ''', m.LateFutureImport) 525 | 526 | 527 | 528 | class TestSpecialAll(harness.Test): 529 | """ 530 | Tests for suppression of unused import warnings by C{__all__}. 531 | """ 532 | def test_ignoredInFunction(self): 533 | """ 534 | An C{__all__} definition does not suppress unused import warnings in a 535 | function scope. 536 | """ 537 | self.flakes(''' 538 | def foo(): 539 | import bar 540 | __all__ = ["bar"] 541 | ''', m.UnusedImport, m.UnusedVariable) 542 | 543 | 544 | def test_ignoredInClass(self): 545 | """ 546 | An C{__all__} definition does not suppress unused import warnings in a 547 | class scope. 548 | """ 549 | self.flakes(''' 550 | class foo: 551 | import bar 552 | __all__ = ["bar"] 553 | ''', m.UnusedImport) 554 | 555 | 556 | def test_warningSuppressed(self): 557 | """ 558 | If a name is imported and unused but is named in C{__all__}, no warning 559 | is reported. 560 | """ 561 | self.flakes(''' 562 | import foo 563 | __all__ = ["foo"] 564 | ''') 565 | 566 | 567 | def test_unrecognizable(self): 568 | """ 569 | If C{__all__} is defined in a way that can't be recognized statically, 570 | it is ignored. 571 | """ 572 | self.flakes(''' 573 | import foo 574 | __all__ = ["f" + "oo"] 575 | ''', m.UnusedImport) 576 | self.flakes(''' 577 | import foo 578 | __all__ = [] + ["foo"] 579 | ''', m.UnusedImport) 580 | 581 | 582 | def test_unboundExported(self): 583 | """ 584 | If C{__all__} includes a name which is not bound, a warning is emitted. 585 | """ 586 | self.flakes(''' 587 | __all__ = ["foo"] 588 | ''', m.UndefinedExport) 589 | 590 | # Skip this in __init__.py though, since the rules there are a little 591 | # different. 592 | for filename in ["foo/__init__.py", "__init__.py"]: 593 | self.flakes(''' 594 | __all__ = ["foo"] 595 | ''', filename=filename) 596 | 597 | 598 | def test_usedInGenExp(self): 599 | """ 600 | Using a global in a generator expression results in no warnings. 601 | """ 602 | self.flakes('import fu; (fu for _ in range(1))') 603 | self.flakes('import fu; (1 for _ in range(1) if fu)') 604 | 605 | 606 | def test_redefinedByGenExp(self): 607 | """ 608 | Re-using a global name as the loop variable for a generator 609 | expression results in a redefinition warning. 610 | """ 611 | self.flakes('import fu; (1 for fu in range(1))', m.RedefinedWhileUnused) 612 | 613 | 614 | def test_usedAsDecorator(self): 615 | """ 616 | Using a global name in a decorator statement results in no warnings, 617 | but using an undefined name in a decorator statement results in an 618 | undefined name warning. 619 | """ 620 | self.flakes(''' 621 | from interior import decorate 622 | @decorate 623 | def f(): 624 | return "hello" 625 | ''') 626 | 627 | self.flakes(''' 628 | from interior import decorate 629 | @decorate('value') 630 | def f(): 631 | return "hello" 632 | ''') 633 | 634 | self.flakes(''' 635 | @decorate 636 | def f(): 637 | return "hello" 638 | ''', m.UndefinedName) 639 | 640 | 641 | class Python26Tests(harness.Test): 642 | """ 643 | Tests for checking of syntax which is valid in PYthon 2.6 and newer. 644 | """ 645 | if version_info < (2, 6): 646 | skip = "Python 2.6 required for class decorator tests." 647 | 648 | 649 | def test_usedAsClassDecorator(self): 650 | """ 651 | Using an imported name as a class decorator results in no warnings, 652 | but using an undefined name as a class decorator results in an 653 | undefined name warning. 654 | """ 655 | self.flakes(''' 656 | from interior import decorate 657 | @decorate 658 | class foo: 659 | pass 660 | ''') 661 | 662 | self.flakes(''' 663 | from interior import decorate 664 | @decorate("foo") 665 | class bar: 666 | pass 667 | ''') 668 | 669 | self.flakes(''' 670 | @decorate 671 | class foo: 672 | pass 673 | ''', m.UndefinedName) 674 | --------------------------------------------------------------------------------