Git Product home page Git Product logo

vscode-crystal-ameba's People

Contributors

dependabot[bot] avatar devnote-dev avatar joseafga avatar richarddewit avatar veelenga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vscode-crystal-ameba's Issues

Extension restart and disable commands

Currently when there is an issue with the extension finding the Ameba executable (or after you've just installed Ameba as a dependency) the extension spams the notification bar with "... is not recognised" on Windows or "... ameba: not found" for Linux. Despite the path being later available in the desired location, the extension still complains and a window reload is required for the extension to work. It would be nice if there was a command which simply restarted the extension to do this.

There are also situations where the environment I'm working in doesn't use Ameba, to which the former issue arises again... A command to disable the extension in that workspace (or at least just turn it off) would be highly appreciated.

Unable to install, there is no available version compatible with VS Code '1.22.2'

Thanks for the time you've put towards a linter for Crystal!

The issue I'm having is in the title, can't get this plugin to work with the described version. Is there a minimum version of vscode required? (just seen the latest version of vscode is 1.32, will try and update if not)

I'm able to install ameba via home-brew and is working from the command line correctly ๐Ÿ‘

Environment
Crystal Version 0.27.2
OSX Version Mojave 10.14

Run ameba via WSL

I run my VS Code in Windows and using Crystal tools via wsl interface.

Running VS Code in WSL mode is not feasible for me since my project has a large amount of files that make VS Code WSL mode consumes a lot of memory and CPU to watch those files (yes even if those files are explicitly ignored).

Is there anyway to set the absolute path for ameba (like in the VS Code Crystal extension) so I can prefix the command path with wsl to make it works in windows?

I tried to create an ameba.bat with this content, but it doesn't seem to work:

wsl /usr/bin/ameba %*

Visual Studio Code open ameba issue on a separate window

For example if I write this simple code:

# TODO: Write documentation for `Web`
module Web
  require "kemal"

  VERSION = "0.1.0"

  get "/" do
    "Hello World!"
  end

  Kemal.run
end

It gives a:

syntax error in 'STDIN:4:3': can't require inside type declarations

on another windows on save only, so you have to undo the save and correct.

Missing icon

The extension is missing the icon, using the default - generic - instead.

Add option to lint while typing instead of waiting for file save

While browsing through the source code I noticed that the getConfig method returns onSave: true.
Would it be possible to add a configuration so that we can change this settings to lint while writing the code instead of only checking after saving ?
Similar to ruby-lsp's behaviour with Rubocop

ruby.rb.-.the-hub.WSL_.Ubuntu.-.Visual.Studio.Code.2024-02-18.17-35-56.mp4

/bin/sh: 1: ameba: not found

After installing the extension this warning appeared /bin/sh: 1: ameba: not found. I'm using ameba as a dependency of my project.

Crystal 0.34.0 [4401e90f0] (2020-04-06)

LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu

Shards 0.10.0 [4091ac5] (2020-04-06)

Ameba 1.5.0 error when config file is not used

I was getting the message "Ameba: failed to parse JSON response."
Inspecting in the console the error was:

Ameba: failed parsing JSON: SyntaxError: Unexpected token 'E', "Error: Una"... is not valid JSON

Then checking the STDOUT of the command I got the following:

Error: Unable to load config file: Config file does not exist /my/path/to/.ameba.yml

Searching a bit, I see the new Ameba 1.5.0 raises exception when --config argument is used but file (.ameba.yml) does not exist. Apparently this did not happen in previous versions.

Checking how the extension treats the configuration file, I found this condition that I don't quite understand the sense of.

if (this.config.configFileName.length) {
const dir = workspace.getWorkspaceFolder(document.uri)!.uri.fsPath;
args.push('--config', path.join(dir, this.config.configFileName));
}

I think it should be checked if that file exists and not the length of filename.

Possible solution would be:

diff --git a/src/ameba.ts b/src/ameba.ts
index 56b5b43..60474ec 100644
--- a/src/ameba.ts
+++ b/src/ameba.ts
@@ -1,5 +1,6 @@
 import { exec } from 'child_process';
 import * as path from 'path';
+import { existsSync } from 'fs';
 import {
     commands,
     Diagnostic,
@@ -32,10 +33,9 @@ export class Ameba {
         }
 
         const args = [this.config.command, document.fileName, '--format', 'json'];
-        if (this.config.configFileName.length) {
-            const dir = workspace.getWorkspaceFolder(document.uri)!.uri.fsPath;
-            args.push('--config', path.join(dir, this.config.configFileName));
-        }
+        const dir = workspace.getWorkspaceFolder(document.uri)!.uri.fsPath;
+        const configFile = path.join(dir, this.config.configFileName);
+        if (existsSync(configFile)) args.push('--config', configFile);
 
         const task = new Task(document.uri, token => {
             const proc = exec(args.join(' '), (err, stdout, stderr) => {

Ameba::Config.each_config_path already checks if the config file exists in the current directory as well as in the user's home. Perhaps the better approach is to remove this from the extension and let Ameba handle it itself.

Extension fails with error "Could not execute Ameba file."

Hello ๐Ÿ‘‹
I wanted to install Ameba globally on my system but after doing so the extension is not able to execute the command anymore for some reason.

I've moved the bin/ameba executable inside my $HOME/.asdf/plugins/crystal/bin directory and added the directory to my PATH by writing export PATH="$HOME/.asdf/plugins/crystal/bin:$PATH" in my .zshrc config file.

When I run the command form a terminal everything works fine

โžœ  fullstack-challenges-crystal git:(master) โœ— ameba
Inspecting 11 files

..F........

00-Setup/00-Demo/src/demo.cr:4:3 [Correctable]
[C] Style/RedundantReturn: Redundant `return` detected
> return Math::PI * radius**2
  ^-------------------------^

Finished in 15.31 milliseconds
11 inspected, 1 failure

But I try to run the extension I have an error message that says
image

I've had a look at https://github.com/crystal-ameba/vscode-crystal-ameba/blob/master/src/configuration.ts and I don't see any reason it would be able to run the command.
I do not have a local bin/ameba file so the command should just be ameba which works when I run it as shown above.

Would you have any idea as to what the problem might be ?

Very liberal with the color underlining, problem level also questionable

Here's a photo:

Screen Shot 2019-06-06 at 10 42 59 PM

All of this highlighting is because the cyclomatic complexity warning. I think two things should be changed:

  • The only underlined part should be the method definition/signature, not the entire body of the method
  • It should not be underlined in red, because it is not an error - typically linter suggestions like this would be done in a green underline. I assume this is because right now it's logged as an "error" and not a linter suggestion.

Invalid Arguements Error

Upon install this extension, I receive the following error:

Error: Invalid arguments
	at new f (/home/exarch/Downloads/VSCode-linux-x64/VSCode-linux-x64/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:97:15156)
	at /home/exarch/.vscode/extensions/veelenga.crystal-ameba-0.1.0/out/ameba.js:56:39
	at Array.forEach (<anonymous>)
	at /home/exarch/.vscode/extensions/veelenga.crystal-ameba-0.1.0/out/ameba.js:53:35
	at ChildProcess.exithandler (node:child_process:417:5)
	at ChildProcess.emit (node:events:513:28)
	at maybeClose (node:internal/child_process:1121:16)
	at Socket.<anonymous> (node:internal/child_process:479:11)
	at Socket.emit (node:events:513:28)
	at Pipe.<anonymous> (node:net:757:14)
$onExtensionRuntimeError @ mainThreadExtensionService.ts:82

This happens in the latest version of Visual Studio Code, Code OSS, and Codium.

.ameba.yml config file ingored

VSCode shows problems, which are ignored in my .ameba.yml config file. When i run ameba from command line, all is OK (no problems).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.