{"action":"created","issue":{"url":"https://api.github.com/repos/realm/SwiftLint/issues/711","repository_url":"https://api.github.com/repos/realm/SwiftLint","labels_url":"https://api.github.com/repos/realm/SwiftLint/issues/711/labels{/name}","comments_url":"https://api.github.com/repos/realm/SwiftLint/issues/711/comments","events_url":"https://api.github.com/repos/realm/SwiftLint/issues/711/events","html_url":"https://github.com/realm/SwiftLint/pull/711","id":162229998,"number":711,"title":"⚠️ WIP - Native plugins support","user":{"login":"zats","id":2688806,"avatar_url":"https://avatars.githubusercontent.com/u/2688806?v=3","gravatar_id":"","url":"https://api.github.com/users/zats","html_url":"https://github.com/zats","followers_url":"https://api.github.com/users/zats/followers","following_url":"https://api.github.com/users/zats/following{/other_user}","gists_url":"https://api.github.com/users/zats/gists{/gist_id}","starred_url":"https://api.github.com/users/zats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zats/subscriptions","organizations_url":"https://api.github.com/users/zats/orgs","repos_url":"https://api.github.com/users/zats/repos","events_url":"https://api.github.com/users/zats/events{/privacy}","received_events_url":"https://api.github.com/users/zats/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-06-24T20:59:32Z","updated_at":"2016-06-28T05:02:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/realm/SwiftLint/pulls/711","html_url":"https://github.com/realm/SwiftLint/pull/711","diff_url":"https://github.com/realm/SwiftLint/pull/711.diff","patch_url":"https://github.com/realm/SwiftLint/pull/711.patch"},"body":"## Into\r\nThis feature came to be as a possible solution to our need to run GraphQL queries validation against scheme allowing queries to be an organic part of the `.swift` source file and an external file. We wanted it to be part of the build process. All these factors made swiftlint an ideal candidate. However builtin rule system while powerful doesn't allow for code execution allow us to achieve it.\r\nAs a potential use case, I can see external plugins for spell checking of strings and comments that would allow `swiftlint autocorrect` to automatically fix spelling mistakes as a part of the build process etc. Also it would open door to adhoc, domain specific and niche rules without need to contribute it back to swiftlint.\r\n\r\n## Plugins infrastructure\r\nPlugin is a bundle with a principle class conforming to the `Rule` type. For now it has to be `class` and not a `struct` for the runtime to be able to address it. I used `NSBundle` infrastructure to load external code. \r\nPlugin should be linked against `SwiftLintFramework` to be able to address appropriate types which might be the problem if the framework is being updated and plugin is not. I'd like to hear your opinion on this one.\r\nThis PR comes with a sample rule that compiles into `.plugin` bundle and can be referenced when running `rules`, `autocorrect` and `lint` commands by adding flag `--plugins ~/swiftlint/plugins/PuppetPlugin.plugin`. This plugin doesn't do match, it allows to specify whether it should fail and what is the severity of the failure. I used it as an example and for integration tests.\r\n\r\n## Integration tests \r\nSince plugin infrastructure is a layer I added mostly on top of the command line app and not the framework I found that it is not that easy to test the app itself (or rather I couldn't find an easy way). I decided to go with a completely opaque approach of launching `swiftlint` binary that can be found in the tests bundle folder. But if you think it's better to test the swiftlint.app I'm open to suggestions.\r\n\r\n## Open issues\r\nAs you can see, PuppetPlugin is configured not to include swift libraries relying on the swiftlint use the same version of swift. Result of running plugin that uses different version of Swift against swiftlint is undefined, and, to be honest is not quite clear to me.\r\n\r\nWhile I understand this feature might not be something authors of the library planned for, I think that added value can enrich the capabilities of swiftlint with features that might be beyond traditional scope of linting. I'd appreciate your feedback on this."},"comment":{"url":"https://api.github.com/repos/realm/SwiftLint/issues/comments/228948903","html_url":"https://github.com/realm/SwiftLint/pull/711#issuecomment-228948903","issue_url":"https://api.github.com/repos/realm/SwiftLint/issues/711","id":228948903,"user":{"login":"zats","id":2688806,"avatar_url":"https://avatars.githubusercontent.com/u/2688806?v=3","gravatar_id":"","url":"https://api.github.com/users/zats","html_url":"https://github.com/zats","followers_url":"https://api.github.com/users/zats/followers","following_url":"https://api.github.com/users/zats/following{/other_user}","gists_url":"https://api.github.com/users/zats/gists{/gist_id}","starred_url":"https://api.github.com/users/zats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zats/subscriptions","organizations_url":"https://api.github.com/users/zats/orgs","repos_url":"https://api.github.com/users/zats/repos","events_url":"https://api.github.com/users/zats/events{/privacy}","received_events_url":"https://api.github.com/users/zats/received_events","type":"User","site_admin":false},"created_at":"2016-06-28T05:02:21Z","updated_at":"2016-06-28T05:02:21Z","body":"Hi @norio-nomura, thanks a lot for your help!\r\n\r\nI think the failure has to do with the fact I created \"integration tests\" target that finds `swiftlint` binary in the test product folder and calls various commands (using `NSTask`) on it directly observing results.\r\nEvery attempt to call commands on CI fails with \r\n```\r\ndyld: Library not loaded: @rpath/libswiftCore.dylib\r\nReferenced from: /Users/travis/Library/Developer/Xcode/DerivedData/SwiftLint-guwhnovfcgsqoagacmxaqgxzqosy/Build/Intermediates/CodeCoverage/Products/Debug/swiftlint\r\nReason: image not found\r\n```\r\n\r\nAll the targets I added have `LD_RUNPATH_SEARCH_PATHS` set to `“$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks\"`\r\n\r\nTo be honest, I’m not sure where else can I set this flag :)"}}
{"actor":{"display_login":"zats"}}