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

Ruby Errors Inserted after Beautify #2092

Closed
AGMNS opened this issue Mar 26, 2018 · 14 comments · Fixed by #2096
Closed

Ruby Errors Inserted after Beautify #2092

AGMNS opened this issue Mar 26, 2018 · 14 comments · Fixed by #2096
Assignees

Comments

@AGMNS
Copy link

AGMNS commented Mar 26, 2018

After updating Atom-Beautify today to 0.32.2 within Atom 1.25.0 64x and running against ruby code error results are inserted at the top of the code. I have uninstalled and reinstalled Beautify and have also checked with another user who now has the same issue. This may be related to the version of Atom, I'm not sure. In addition if code is copied and pasted after running beautify additional line feeds are added to the existing line feeds as you can see below.

Before Beautify:

require 'pp'
p 0
require_relative 'user'
p 2
user = User.new '[email protected]', 'Inspector 1'
pp user
p 1
user.save

After Beautify:

Inspecting 1 file
C

Offenses:

atom-beautify.rb:1:1: C: Naming/FileName: The name of this source file (atom-beautify.rb) should use snake_case.
require 'pp'
^

1 file inspected, 1 offense detected
====================
require 'pp'

p 0

require_relative 'user'

p 2

user = User.new '[email protected]', 'Inspector 1'



pp user

p 1

user.save
@stevenzeck
Copy link
Contributor

Please run the Debug command in Atom under Packages -> Atom Beautify -> Debug. Copy/paste the contents to a gist here on GitHub. This will give us more information to help look into this issue.

@AGMNS
Copy link
Author

AGMNS commented Mar 26, 2018

Here's the link to the debug info:

https://gist.github.com/AGMNS/6be05de0536f12b0ebd060b226f4a7f8

@AGMNS AGMNS closed this as completed Mar 26, 2018
@AGMNS AGMNS reopened this Mar 26, 2018
@stevenzeck
Copy link
Contributor

stevenzeck commented Mar 26, 2018

I'm getting the same output in my console, but not in the editor. So it could be a Windows specific bug, or a bug with the old @run function.

@AGMNS please try this and see if it makes a difference:

  1. Go into Atom Beautify's settings and cut (or copy and remove) the Rubocop path that you have under Ruby. It should be empty.

screen shot 2018-03-26 at 12 02 44 pm

  1. Expand the "Executables" section and look for Rubocop and expand that
  2. Paste in the path there

screen shot 2018-03-26 at 12 04 13 pm

Restart Atom (just in case) and see if that makes a difference. Looking for a Windows machine so I can look into further.

@AGMNS
Copy link
Author

AGMNS commented Mar 26, 2018

In both instances the entry is empty in my settings. Since it is only displaying "Default:" I'm assuming there's really nothing to do there.

Strange that both my brother and I are experiencing this same problem after the latest Atom 64x release and updating the Atom-Beautify.

AGMNS

@stevenzeck
Copy link
Contributor

Interesting, the logs point to the Rubocop path being C:\Ruby23\bin\rubocop.BAT, unless it's in your environment variable path and it found it that way.

The only other thing is that it might not like the file being on an E drive. Can you copy/paste the contents into an unsaved file, change the grammar of the file to Ruby, and beautify it? Does it have the same output?

@AGMNS
Copy link
Author

AGMNS commented Mar 26, 2018

I copied and pasted the contents and saved the file to c:/users/AGMNS

Opened the file in Atom and beautified. Same result.

@stevenzeck
Copy link
Contributor

OK, I'll have to find a Windows machine to see what is going on.

@AGMNS
Copy link
Author

AGMNS commented Mar 28, 2018

OK, we've done some digging on our end and discovered something. How this translates into the broader scope of what's happening will require some digging. I'm suspecting the latest release of Atom may have something to do with it. Something has changed with the windows environment.

The code below in the latest Atom-Beautifier is the same code that exists in the previous version of Atom-Beautifier that worked. That's why I'm wondering if something changed in that last Atom release 12 days ago.

Here's the steps in Atom.

  1. Open Atom
  2. Go to Packages --> Atom-Beautify -- Settings
  3. Choose View Code
  4. go to SRC --> Beautifiers and open rubocop.coffee and go to line 83 see below
        result = stdout.split("====================\n")
        result[result.length - 1]

You'll notice that the split happens on the sting of equal signs and a line feed \n. HOWEVER if on the windows machine you view hidden characters you will see that Atom inserts a \r\n. So I guessed that this might have something to do with it and changed the line to include \r\n, Saved and restarted Atom.

With that change Atom-Beautify returns the script beautified as it should without the error comments at the top.

Hope this points in the right direction.

@stevenzeck
Copy link
Contributor

Thanks for the information, that is helpful. I changed my Atom settings to use CRLF instead of LF, and still wasn't able to reproduce it, which leads me to believe it is very specific to Windows or at least Rubocop Windows. But weird that our CI build for Windows doesn't have a problem.

Anyhow, a bug is a bug. We'll have to look at the OS and determine whether it should be \r\n or just \n. Related to #1776

@stevenzeck
Copy link
Contributor

stevenzeck commented Mar 28, 2018

@AGMNS I started a PR to fix this, however the Windows CI build (using AppVeyor) failed. Can you try replacing your rubocop.coffee with the contents here: https://raw.githubusercontent.com/szeck87/atom-beautify/132f7026cd174a08f2b70bef29fdafa872d2f0e8/src/beautifiers/rubocop.coffee. All it does it requires the os module from node and uses its EOL constant in place of \n. If this fixes it for you, then I need to look into this more as it may not be limited to the OS EOL.

EDIT: Can you also tell me what you have in the line-ending-selector package for Default line ending? And also for those Ruby files what your status bar has for the line ending? Looks like this (for me it's LF):
screen shot 2018-03-28 at 12 19 45 pm

@AGMNS
Copy link
Author

AGMNS commented Mar 28, 2018

Ok, that works without a problem.

Status bar is CRLF

line-ending-selector package is set to OS Default

AGMNS

@stevenzeck
Copy link
Contributor

OK, I'm not able to make sense of what is happening. I'll need to investigate further.

@stevenzeck
Copy link
Contributor

@AGMNS I put an ugly hack together, if you want to try it out look at #2096.

@stevenzeck
Copy link
Contributor

Fixed with v0.32.5.

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

Successfully merging a pull request may close this issue.

2 participants