Komodo / KomodoEdit

Komodo Edit is a fast and free multi-language code editor. Written in JS, Python, C++ and based on the Mozilla platform.
http://www.komodoide.com/komodo-edit
Other
2.15k stars 302 forks source link

Rubocop integration #2287

Closed Defman21 closed 7 years ago

Defman21 commented 7 years ago

Short Summary

Rubocop is pep8 in Ruby world, and I'd want to see it in Komodo :)

Defman21 commented 7 years ago

It supports JSON output so it could be pretty easy to integrate.

Defman21 commented 7 years ago

An example JSON:

{
  "metadata": {
    "rubocop_version": "0.47.1",
    "ruby_engine": "ruby",
    "ruby_version": "2.3.3",
    "ruby_patchlevel": "222",
    "ruby_platform": "x86_64-linux"
  },
  "files": [
    {
      "path": "lib/twitch_bot.rb",
      "offenses": [
        {
          "severity": "convention",
          "message": "Missing top-level module documentation comment.",
          "cop_name": "Style/Documentation",
          "corrected": null,
          "location": {
            "line": 4,
            "column": 3,
            "length": 6
          }
        }
      ]
    }
  ],
  "summary": {
    "offense_count": 1,
    "target_file_count": 1,
    "inspected_file_count": 1
  }
}
Defman21 commented 7 years ago

Or you can simply point me to the right direction and I'll send a pull request to you. 😇

Naatan commented 7 years ago

Can you explain what this is and what you imagine "integration" would entail?

Defman21 commented 7 years ago

Rubocop checks your code in the same way as pep8 does. It has a lot of rules that you should follow to keep your code clean. It'd give you different warnings so you'd fix them. Basically, it's a linter but it checks your code style and not errors in it.

Defman21 commented 7 years ago

And I think I've used the integration word wrong 😛

mitchell-as commented 7 years ago

Sounds like just another linter like pylint or something. Adding to backlog.

Defman21 commented 7 years ago

Yep, you're right.

Defman21 commented 7 years ago

I assume I need to modify this file to add a linter? https://github.com/Komodo/KomodoEdit/blob/master/src/lint/koCSSExLinter.py

Oops that's for CSS.

Defman21 commented 7 years ago

@mitchell-as PR's welcome? :)

mitchell-as commented 7 years ago

Sure, if you're feeling so inclined :)

Defman21 commented 7 years ago

Would you rather accept this as a PR or as an add-on? I've managed to make it working in both cases.

th3coop commented 7 years ago

I think an addon would be preferable for now but that's more @Naatan's call. Please post your solution to the problems you were having back in the forum post you started.

Defman21 commented 7 years ago

In case you'd want to be it a built-in linter, here's the code you might want to review:

https://github.com/Defman21/korubocop/blob/master/components/koRubocopLinter.py

Note there's a case when I lint the actual file instead of a temporary one. This is needed when there's a rubocop configuration in the root of a project which has relative paths in it's config blocks (such as directories to ignore, etc).

Naatan commented 7 years ago

@Defman21 Looks great. PR it? :)

Defman21 commented 7 years ago

I'll do that tomorrow :)

mitchell-as commented 7 years ago

Retargeting for 11 in order to review PR.