Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run cloudformation linter #2547

Closed
sushovannits opened this issue May 30, 2019 · 6 comments
Closed

Unable to run cloudformation linter #2547

sushovannits opened this issue May 30, 2019 · 6 comments

Comments

@sushovannits
Copy link

Information

VIM version

sushovanp@dev-sushovanp10  /tmp  vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 22 2019 19:03:04)
Included patches: 1-503, 505-680, 682-1283

Operating System:

      System Version: macOS 10.14.5 (18F132)
      Kernel Version: Darwin 18.6.0

What went wrong

I am unable to make the cloudformation linter work.

Reproducing the bug

  1. Installed cfn-python-lint.
    sushovanp@dev-sushovanp10  /tmp  cfn-lint --version
    cfn-lint 0.19.1
    
  2. The set this in my vimrc (just to test):
     let g:ale_linters = {'python': ['pylint'],                                                                                                                                                                                                     
         \ 'yaml' : ['cloudformation']} 
    
  3. Then opening a cloudformation yaml file and using :ALEInfo shows this:
  Current Filetype: yaml                                                                                                                                                                                                                         
  Available Linters: ['swaglint', 'yamllint']                                                                                                                                                                                                     
  Enabled Linters: []     

:ALEInfo

  Current Filetype: yaml                                                                                                                                                                                                                        
 Available Linters: ['swaglint', 'yamllint']                                                                                                                                                                                                    
   Enabled Linters: []                                                                                                                                                                                                                          
  Suggested Fixers:                                                                                                                                                                                                                             
   'prettier' - Apply prettier to a file.                                                                                                                                                                                                       
   'remove_trailing_lines' - Remove all blank lines at the end of a file.                                                                                                                                                                       
   'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.                                                                                                                                                      
  Linter Variables:                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                
  Global Variables:                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                
 let g:ale_cache_executable_check_failures = v:null                                                                                                                                                                                             
 let g:ale_change_sign_column_color = v:null                                                                                                                                                                                                    
 let g:ale_command_wrapper = v:null                                                                                                                                                                                                             
 let g:ale_completion_delay = v:null                                                                                                                                                                                                            
 let g:ale_completion_enabled = 0                                                                                                                                                                                                               
 let g:ale_completion_max_suggestions = v:null                                                                                                                                                                                                  
 let g:ale_echo_cursor = 1                                                                                                                                                                                                                      
 let g:ale_echo_msg_error_str = 'Error'                                                                                                                                                                                                         
 let g:ale_echo_msg_format = v:null                                                                                                                                                                                                             
 let g:ale_echo_msg_info_str = 'Info'                                                                                                                                                                                                           
 let g:ale_echo_msg_warning_str = 'Warning'                                                                                                                                                                                                     
 let g:ale_enabled = 1                                                                                                                                                                                                                          
 let g:ale_fix_on_save = 0                                                                                                                                                                                                                      
 let g:ale_fixers = {}                                                                                                                                                                                                                          
 let g:ale_history_enabled = 1                                                                                                                                                                                                                  
 let g:ale_history_log_output = 1                                                                                                                                                                                                               
 let g:ale_keep_list_window_open = v:null                                                                                                                                                                                                       
 let g:ale_lint_delay = 200                                                                                                                                                                                                                     
 let g:ale_lint_on_enter = 0                                                                                                                                                                                                                    
 let g:ale_lint_on_filetype_changed = 1                                                                                                                                                                                                         
 let g:ale_lint_on_insert_leave = 0                                                                                                                                                                                                             
 let g:ale_lint_on_save = 1                                                                                                                                                                                                                     
 let g:ale_lint_on_text_changed = 'never'                                                                                                                                                                                                       
 let g:ale_linter_aliases = {}                                                                                                                                                                                                                  
 let g:ale_linters = {'yaml': ['cloudformation'], 'python': ['pylint']}                                                                                                                                                                         
 let g:ale_linters_explicit = 0                                                                                                                                                                                                                 
 let g:ale_list_vertical = v:null                                                                                                                                                                                                               
 let g:ale_list_window_size = v:null                                                                                                                                                                                                            
 let g:ale_loclist_msg_format = v:null                                                                                                                                                                                                          
 let g:ale_lsp_root = {}                                                                                                                                                                                                                        
 let g:ale_max_buffer_history_size = 20                                                                                                                                                                                                         
 let g:ale_max_signs = v:null                                                                                                                                                                                                                   
 let g:ale_maximum_file_size = v:null                                                                                                                                                                                                           
 let g:ale_open_list = v:null                                                                                                                                                                                                                   
 let g:ale_pattern_options = v:null                                                                                                                                                                                                             
 let g:ale_pattern_options_enabled = v:null                                                                                                                                                                                                     
 let g:ale_set_balloons = 0                                                                                                                                                                                                                     
 let g:ale_set_highlights = 0                                                                                                                                                                                                                   
 let g:ale_set_loclist = 1                                                                                                                                                                                                                      
 let g:ale_set_quickfix = 0          
@w0rp
Copy link
Member

w0rp commented Jun 2, 2019

You need to update your filetype to yaml.cloudformation when editing YAML files that are cloudformation files.

@w0rp w0rp closed this as completed Jun 2, 2019
@RyanSquared
Copy link
Member

This can be done by either an exrc file in the project directory, a custom filetype checker, or a modeline in each individual file.

@tlelson
Copy link

tlelson commented Jan 30, 2021

I believe I have the same configuration but ALEInfo shows that cfn-lint is not Enabled.

Closing vim and running the linter gives errors bellow:

(general) DELP ❯ cfn-lint GlueCFN/template.yaml  | head
E3012 Property Resources/PostProcess/Properties/Command/PythonVersion should be of type String
GlueCFN/template.yaml:24:17
...

Full ALEInfo:

 Current Filetype: cloudformation.yaml
Available Linters: ['cloudformation', 'swaglint', 'yamllint']
  Enabled Linters: ['swaglint', 'yamllint']
  Ignored Linters: []
 Suggested Fixers:
  'prettier' - Apply prettier to a file.
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
  'yamlfix' - Fix yaml files with yamlfix.
 Linter Variables:
let g:ale_yaml_swaglint_executable = 'swaglint'
let g:ale_yaml_swaglint_use_global = 0
let g:ale_yaml_yamllint_executable = 'yamllint'
let g:ale_yaml_yamllint_options = ''
 Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = v:null
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_disable_lsp = 0
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {'cloudformation': ['cfn-lint']}
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '✗'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '✗'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_sign_highlight_linenrs = 0
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:
(executable check - failure) swaglint
(executable check - failure) yamllint

What have I done wrong here?

@w0rp
Copy link
Member

w0rp commented Jan 31, 2021

The linter was set up so let g:ale_linters = {'cloudformation': ['cloudformation']} was what you needed, but I've added an alias in a new commit so let g:ale_linters = {'cloudformation': ['cfn-lint']} should also work, as I can see other people doing the same thing. If you pull the latest commit it should start running.

@tlelson
Copy link

tlelson commented Jan 31, 2021

Thanks @w0rp I see the new alias in c747c27. Works perfectly.

Tell me, is the g:ale_linters map not a map of filetype : linter_executable and rather filetype : linter_alias ?

What is the correct way to understand this map ?

@w0rp
Copy link
Member

w0rp commented Feb 7, 2021

:help g:ale_linters should explain everything. The values on the right are the names of linters defined for ALE, which may not be the same as the executable names. Most of the time the linter name is the same as the executable name, which makes them more obvious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants