-
Notifications
You must be signed in to change notification settings - Fork 4
Conversation
I suggest this to be released as v1.6.0 as configuration options aren't backwards compatible. Once this PR is merged I can make another PR for #24 and add the option to configure when to lint, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's what I see just looking over the code.
.editorconfig
Outdated
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Apparently you didn't have this file there when editing it, as this is missing the trailing newline 😉.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did, but as you can see, it doesn't include an entry for a .editorconfig 😉
lib/main.js
Outdated
|
||
this.subscriptions = new CompositeDisposable(); | ||
|
||
// FIXME: Remove after a few versions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 This setting never existed here, as such we don't need to include code removing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took this from linter-phpcs
, don't look at me 😉
} | ||
|
||
loadDeps(); | ||
const fileDir = path.dirname(filePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need a check that filePath
isn't null
, although it should be impossible, sometimes linter
will call Providers with TextEditor
s that don't have this defined (usually on restoring a session on restarting Atom).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, this needs to be fixed in linter-phpcs
as well then, as far as I can remember.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, many of the providers still need the guard added to them, for some reason it's rarely an issue for most providers (I think it's a race condition in the TextEditor
initializing and maybe they are slow enough it's not an issue? 😕).
package-lock.json
Outdated
@@ -0,0 +1,1620 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 Until Greenkeeper figures out updating of this automatically in their main integration I'm holding off on adding this to more repositories as currently it is a very manual process that gets forgotten. The version of npm
in apm
doesn't even utilize this anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, I'll remove it 👍
lib/main.js
Outdated
scope: 'file', | ||
lintOnFly: false, | ||
lintsOnChange: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥🐛 This is still a v1 provider, so this needs to stay lintOnFly
. Also, as we aren't passing in the file contents this needs to stay false
!
lib/main.js
Outdated
this.subscriptions.dispose(); | ||
}, | ||
|
||
provideLinter() { | ||
return { | ||
name: 'PHPMD', | ||
grammarScopes: ['text.html.php', 'source.php'], | ||
grammarScopes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 Since there is no need to change the scopes, let's just keep these as statically declared here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took this straight from linter-phpcs
, I'm not familiar with these kind of packages and the comment made sense.
lib/main.js
Outdated
} | ||
} | ||
|
||
// Check if a rulesets file exists and handle it | ||
const confFileNames = ['phpmd.xml', 'phpmd.xml.dist', 'phpmd.ruleset.xml']; | ||
const confFile = await helpers.findAsync(fileDir, confFileNames); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐎 Put this behind a check on this.autoConfigSearch
, there's no point in spending the I/O time searching for these files if we aren't going to use them!
The rulesets
declaration down on 114 could probably be moved partially into here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👍
lib/main.js
Outdated
}; | ||
|
||
const output = await helpers.exec(executablePath, parameters, options); | ||
if (confFile) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this up underneath the projectPath
logic, and do similar logic there. That way all the cwd
modifying logic is in one place. It might make sense to have both set a cwd
variable instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, I'll have a look!
lib/main.js
Outdated
} | ||
} | ||
|
||
// Local variables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 this, see below for reasoning.
@@ -0,0 +1,7 @@ | |||
root = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this to the version used elsewhere? (this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure no problem 👍
Breaking changes in the configuration would need a major release btw. |
I'll get on with the changes @Arcanemagus, thank you for your feedback and I'll update this PR tomorrow 👍 |
It took me a little longer, things came up but I think I fixed it all without breaking anything 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there!
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still missing the ending newline 😛.
Note, you can change the whitespace
package's options to handle this for you automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fial. Fail.
lib/main.js
Outdated
const rulesetPath = await helpers.findAsync(filePath, rulesets); | ||
if (rulesetPath !== null) { | ||
ruleset = rulesetPath; | ||
if (fileText === '' || filePath === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can also be undefined
, this is one of the cases where it should just be if (fileText === '' || !filePath)
.
lib/main.js
Outdated
}), | ||
atom.config.observe('linter-phpmd.rulesets', (value) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember how I said to remove that check on the executableTimeout
from phpcs
? We actually need the same code, but for this setting, sorry!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, working on multiple projects so I'll have to dig into that to see what you mean 😜
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, to make it backwards compatbile! 👍
package.json
Outdated
"default": -1, | ||
"minimum": -1, | ||
"description": "Rule priority threshold; rules with lower priority than this will not be used.", | ||
"order": 7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 5 -> 7?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, I must have removed an option and not updated the order.
Okay done! 👍 |
lib/main.js
Outdated
|
||
// Backwards compatibility | ||
if (atom.config.get('linter-phpmd.rulesets') !== undefined) { | ||
this.rulesOrConfigFile = atom.config.get('linter-phpmd.rulesets'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
atom.config.set('linter-phpmd.rulesOrConfigFile', atom.config.get('linter-phpmd.rulesets'));
We want to save their old setting, not grab it this one time and then lose it forever 😉.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh, you're right 🙄 where's my head at? 😜
There you go, that should be it. Lesson learnt on linters, thanks! Possibly hate writing them more than using them 😜 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for working through this!
Published as v2.0.0, thanks again! |
Awesome, you're very welcome! Thanks again for your directions 👍 Next on the list is probably being able to lint on-the-fly but we'll see, first have to get back to work 😆 |
I'm not sure I'm a fan personally of the way to get linters like this to lint on the fly. The only way that has been figured out so far is to create a temporary file from the current contents, and then lint that. This only works on simple linters that have no dependency on the state of the rest of the project, and causes a lot of I/O. |
As I was getting sick and tired of constantly getting the error message that PHPMD could not be executed in my projects because of a missing phpmd.xml, I decided to make the changes that have already been made to
linter-phpcs
😄linter-phpcs
)Fixes #102.
Fixes #106.