SublimeLinter / SublimeLinter-rubocop

SublimeLinter 3 plugin for Ruby, using rubocop.
MIT License
159 stars 40 forks source link

Not working with SublimeLinter 4 #49

Closed meetajhu closed 6 years ago

meetajhu commented 6 years ago

This Linter was working flawlessly with SublimeLinter3 until the recent forced update to SublimeLinter 4. No linting or no error in console. From Console: reloading plugin SublimeLinter-rubocop.linter

Then nothing happens. Rubocop works in CL.

kaste commented 6 years ago

That's not enough info to debug an issue, honestly. Enable debug mode, restart Sublime and post the console log.

If it really does absolutely nothing (no warnings) then it typically means that it doesn't recognize the syntax of your view/buffer.

meetajhu commented 6 years ago

Is there any other better way to debug other than console errors?

kaste commented 6 years ago

I don't understand. You probably don't want to debug python code here and now.

foton commented 6 years ago

Startup Sublime 3 in debug mode:

DPI scale: 1
startup, version: 3143 linux x64 channel: stable
executable: /opt/sublime_text/sublime_text
working dir: /
packages path: /home/foton/.config/sublime-text-3/Packages
state path: /home/foton/.config/sublime-text-3/Local
zip path: /opt/sublime_text/Packages
zip path: /home/foton/.config/sublime-text-3/Installed Packages
ignored_packages: ["GitGutter", "Vintage"]
ignoring deprecated syntax definition: Packages/Ruby on Rails snippets/HTML (Rails).tmLanguage
pre session restore time: 0.159505
startup time: 0.375407
first paint time: 0.390357
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.01-pygments
reloading plugin 0_package_control_loader.50-markupsafe
reloading plugin 0_package_control_loader.50-pymdownx
reloading plugin 0_package_control_loader.50-python-markdown
reloading plugin 0_package_control_loader.50-pyyaml
reloading plugin 0_package_control_loader.51-python-jinja2
reloading plugin 0_package_control_loader.55-jsonschema
reloading plugin 0_package_control_loader.55-mdpopups
reloading plugin AdvancedNewFile.AdvancedNewFile
reloading plugin All Autocomplete.all_views_completions
reloading plugin Better CoffeeScript.CoffeeScript
reloading plugin Cucumber.GherkinAutoComplete
reloading plugin Cucumber.table_cleaner
reloading plugin Cucumber.table_commons
reloading plugin Cucumber.table_import
reloading plugin Gherkin (Cucumber) Formatter.__init__
reloading plugin Gherkin (Cucumber) Formatter.sublime-gherkin-formatter
reloading plugin Git.git_commands
reloading plugin GitHub Flavored Markdown Preview.GHMarkdownPreview
reloading plugin Goto Usage.GotoUsage
reloading plugin Goto Usage.__init__
reloading plugin Goto Usage.core
reloading plugin Goto Usage.dep_graph
reloading plugin Goto Usage.utils
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin SublimeLinter-contrib-reek.linter
reloading plugin SublimeLinter-rubocop.linter
reloading plugin SublimeLinter.__init__
reloading plugin SublimeLinter.busy_indicator_view
reloading plugin SublimeLinter.commands
reloading plugin SublimeLinter.goto_commands
reloading plugin SublimeLinter.highlight_view
reloading plugin SublimeLinter.log_handler
reloading plugin SublimeLinter.message_view
reloading plugin SublimeLinter.panel_view
reloading plugin SublimeLinter.status_bar_view
reloading plugin SublimeLinter.sublime_linter
reloading plugin SublimeLinter.tooltips_view
reloading plugin Babel.Babel
plugins loaded
Package Control: No updated packages
Indexing gherkin phrases done

No errors marked in pictogram.rb:

module Catalog
  class Pictogram < ApplicationRecord
    include TrackActivity
    include ActivityTrails

    CODE_REGEXP_STR = '[a-z\-]+'
    self.table_name = 'catalog_pictograms'

    validates :slug,
              presence: true,
              uniqueness: true,
              format: { with: /\A[a-z\-]+\z/, message: I18n.t('catalog.pictogram.errors.slug_have_bad_format') }
    validates :title, presence: true
    validates :view_box, presence: true
    validates :svg_body, presence: true

    scope :by_code, ->(code) { where('codes_csv LIKE ?', "%,#{code.delete(':').strip},%") }

    track_activity

    def full_code
      slug
    end
  end
end

When I run rubocop from shell, 2 offenses are found:

foton@NTB-Mlcosi:~$ rubocop Dokumenty/workspace/queens_fresh/app/models/catalog/pictogram.rb 
Inspecting 1 file
/home/foton/Dokumenty/workspace/queens_fresh/.rubocop.yml: Naming/PredicateName has the wrong namespace - should be Style
/home/foton/Dokumenty/workspace/queens_fresh/.rubocop.yml: Naming/FileName has the wrong namespace - should be Style
Warning: unrecognized cop Rails/HasManyOrHasOneDependent found in /home/foton/Dokumenty/workspace/queens_fresh/.rubocop.yml
Warning: unrecognized cop Rails/CreateTableWithTimestamps found in /home/foton/Dokumenty/workspace/queens_fresh/.rubocop.yml
Warning: unrecognized cop Rails/InverseOf found in /home/foton/Dokumenty/workspace/queens_fresh/.rubocop.yml
Warning: unrecognized cop Style/MixinUsage found in /home/foton/Dokumenty/workspace/queens_fresh/.rubocop.yml
C

Offenses:

Dokumenty/workspace/queens_fresh/app/models/catalog/pictogram.rb:25:23: C: Freeze mutable objects assigned to constants.
    CODE_REGEXP_STR = '[a-z\-]+'
                      ^^^^^^^^^^
Dokumenty/workspace/queens_fresh/app/models/catalog/pictogram.rb:36:1: C: Extra blank line detected.

1 file inspected, 2 offenses detected
foton commented 6 years ago

From now it seems that setting "debug": true in Packages/User/Preferences.sublime-settings does not change console log :-(

kaste commented 6 years ago

The setting is in the SublimeLinter settings not in your main user settings.

foton commented 6 years ago

But it should override it, right? I am unable to locate or write to file Packages/Default/Preferences.sublime-settings !?

kaste commented 6 years ago

Nana, in the menu Preferences > Package Settings > SublimeLinter.

Something like that.

dikond commented 6 years ago

Hi! I also noticed it isn't working with sublime-linter 4. The error I see constantly in the console is: (errors aren't related to this package and I can confirm it's working)

FileNotFoundError: [Errno 2] No such file or directory: '/Users/danny/.rvm/bin/rvm-auto-ruby'

I have rbenv v1.1.1. RVM wasn't installed. I've extracted full log into the gist. Also, I've enabled debug flag and restart the sublime text - here is the log

kaste commented 6 years ago

@dikond Here throws a completely different package.

dikond commented 6 years ago

@kaste I see, sorry for bothering πŸ˜“ Removed all rubocop-related plugins and re-installed SublimeLinter-rubocop. I have 0 errors now, but sublime linter doesn't show violations for some reason now. Although rubocop (gem) does show. But I think it isn't related to this package.

kaste commented 6 years ago

We should figure what command exactly you're running on the cli.

SublimeLinter: #1 SublimeLinter.sublime-package:1184: rubocop: application.rb

['/Users/danny/.rbenv/shims/ruby', '-S', 'rubocop', '--format', 'emacs', '--force-exclusion', '--stdin', '/Users/danny/dev/elixirator/enbro_crm/apps/api_v1/application.rb']

That's really basically the command we're running here (shlexed). More or less you can join here by ' '

SublimeLinter: #1 SublimeLinter.sublime-package:1187: rubocop: cwd: /Users/danny/dev/elixirator/enbro_crm

That's the working dir.

kaste commented 6 years ago

Does it need special environment variables.

I mean it doesn't show any output in your gist

a) It's still working on the problem LOL b) There is zero output, nada

Otherwise it would at least crash

dikond commented 6 years ago

So I tried different variations of commands and here are my results

1) Without --stdin

/Users/danny/.rbenv/shims/ruby -S rubocop --format emacs --force-exclusion /Users/danny/dev/elixirator/enbro_crm/apps/api_v1/application.rb

Result: process either idle or hangs? No output and no prompt in terminal :)

2) Without --force-exclusion & --stdin

/Users/danny () ツ /Users/danny/.rbenv/shims/ruby -S rubocop --format emacs /Users/danny/dev/elixirator/enbro_crm/apps/api_v1/application.rb /Users/danny/dev/elixirator/enbro_crm/apps/api_v1/application.rb:7:18: W: Lint/UnneededDisable: Unnecessary disabling of Metrics/BlockLength. /Users/danny/dev/elixirator/enbro_crm/apps/api_v1/application.rb:263:29: W: Lint/UnneededDisable: Unnecessary disabling of Metrics/BlockLength.

Result: it works!

3) Without --force-exclusion

/Users/danny/.rbenv/shims/ruby -S rubocop --format emacs --force-exclusion /Users/danny/dev/elixirator/enbro_crm/apps/api_v1/application.rb

Result: no output


Gonna check my exclusion rules... But it seems --stdin causes troubles?

dikond commented 6 years ago

Well, I can confirm that SublimeLinter-rubocop is working... here is the gist of a proof. It just doesn't lint in some projects, which makes me think it's 100% related to exclusion rules somehow πŸ˜…

UPDATE: my issue was caused because of exclusion rules and isn't related to this package at all. Thanks for your help! And I'm really sorry for wasting your time πŸ˜“

kaste commented 6 years ago

☺️

Honestly, I don't know what --force-exclusion does. It was there and it is on by default. 😬

foton commented 6 years ago

I fix my issue too, adding "debug": true to Preferences > Package Settings > SublimeLinter > Settings :User reveal, that path "~/.rbenv/shims" is not in paths for Sublime Linter. After adding it (http://sublimelinter.readthedocs.io/en/latest/troubleshooting.html#adding-to-the-paths-setting). Linter works. But results are displayed little differently, so my guess is that previous settings was erased during update of Sublime Linter.

kaste commented 6 years ago

You mean the colors are different?

I've found a comment here https://github.com/SublimeLinter/SublimeLinter/issues/1074#issuecomment-370265068 how to customize the colors.

kaste commented 6 years ago

Don't know. The OP never showed up again, two highjackers are (hopefully) happy, so I'm closing. πŸ’ͺ