Permalink
Browse files

Catch up with Swift 3 and swift-ast 0.1.4 changes

  • Loading branch information...
ryuichis committed Apr 26, 2017
1 parent 722d531 commit b02737efa5289ca79ee143b82d3982a653af12ba
Showing with 1,181 additions and 997 deletions.
  1. +1 −0 .ruby-version
  2. +1 −1 .swift-version
  3. +5 −6 .travis.yml
  4. +5 −0 Gemfile
  5. +53 −0 Gemfile.lock
  6. +29 −0 Guardfile
  7. +6 −32 Makefile
  8. +12 −0 Package.pins
  9. +40 −17 Package.swift
  10. +7 −13 Tests/main.swift → Sources/Lint/ASTContext.swift
  11. +35 −0 Sources/Lint/IssuePool.swift
  12. +20 −0 Sources/Lint/RuleBase.swift
  13. +9 −21 Sources/lint/ASTVisitorRule.swift
  14. +3 −3 Sources/lint/Constant.swift
  15. +11 −11 Sources/lint/Correction.swift
  16. +65 −68 Sources/lint/Driver.swift
  17. +22 −31 Sources/lint/Issue.swift
  18. +14 −14 Sources/lint/Reporter.swift
  19. +23 −31 Sources/lint/Rule.swift
  20. +14 −18 Sources/lint/SourceCodeRule.swift
  21. +15 −28 Sources/lint/reporter/TextReporter.swift
  22. +26 −39 Sources/lint/rule/NoForceCastRule.swift
  23. +15 −28 Sources/swift-lint/main.swift
  24. +0 −110 Tests/ASTVisitorRuleBaseSpec.swift
  25. +6 −8 Tests/{CanarySpec.swift → CanaryTests/CanaryTests.swift}
  26. +25 −0 Tests/CanaryTests/XCTestManifests.swift
  27. +0 −37 Tests/CorrectionSpec.swift
  28. +0 −93 Tests/DriverSpec.swift
  29. +112 −0 Tests/LintTests/ASTVisitorRuleTests.swift
  30. +38 −0 Tests/LintTests/CorrectionTests.swift
  31. +95 −0 Tests/LintTests/DriverTests.swift
  32. +93 −0 Tests/LintTests/RuleProtocolTests.swift
  33. +113 −0 Tests/LintTests/SourceCodeRuleTests.swift
  34. +29 −0 Tests/LintTests/XCTestManifests.swift
  35. +29 −0 Tests/LinuxMain.swift
  36. +59 −0 Tests/ReporterTests/TextReporterTests.swift
  37. +25 −0 Tests/ReporterTests/XCTestManifests.swift
  38. +0 −81 Tests/RuleProtocolSpec.swift
  39. +49 −0 Tests/RuleTests/NoForceCastRuleTests.swift
  40. +43 −0 Tests/RuleTests/XCTestCase+RuleTests.swift
  41. +25 −0 Tests/RuleTests/XCTestManifests.swift
  42. +0 −111 Tests/SourceCodeRuleBaseSpec.swift
  43. +0 −50 Tests/TestUtil.swift
  44. +0 −58 Tests/reporter/TextReporterSpec.swift
  45. +0 −88 Tests/rule/NoForceCastRuleSpec.swift
  46. +9 −0 dogFooding.sh
View
@@ -0,0 +1 @@
2.3.1
View
@@ -1 +1 @@
swift-2.2-SNAPSHOT-2016-01-11-a
3.1
View
@@ -4,12 +4,11 @@ os:
language: generic
sudo: required
dist: trusty
osx_image: xcode7.2
osx_image: xcode8.3
install:
- curl -sL https://gist.github.com/kylef/5c0475ff02b7c7671d2a/raw/621ef9b29bbb852fdfd2e10ed147b321d792c1e4/swiftenv-install.sh | bash
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"
script:
- . ~/.swiftenv/init
- make test
matrix:
allow_failures:
- os: linux
- ./dogFooding.sh -diagnostics-only
after_success:
- eval "$(curl -sL https://swift.vapor.sh/codecov)"
View
@@ -0,0 +1,5 @@
source 'https://rubygems.org'
gem 'rb-readline'
gem 'colored'
gem 'guard-shell'
View
@@ -0,0 +1,53 @@
GEM
remote: https://rubygems.org/
specs:
coderay (1.1.1)
colored (1.2)
ffi (1.9.18)
formatador (0.2.5)
guard (2.14.1)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-shell (0.7.1)
guard (>= 2.0.0)
guard-compat (~> 1.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
lumberjack (1.0.11)
method_source (0.8.2)
nenv (0.3.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rb-fsevent (0.9.8)
rb-inotify (0.9.8)
ffi (>= 0.5.0)
rb-readline (0.5.4)
ruby_dep (1.5.0)
shellany (0.0.1)
slop (3.6.0)
thor (0.19.4)
PLATFORMS
ruby
DEPENDENCIES
colored
guard-shell
rb-readline
BUNDLED WITH
1.13.6
View
@@ -0,0 +1,29 @@
require 'colored'
require 'open3'
clearing :on
guard :shell do
watch(/(.*).swift$/) {|m|
puts "Running tests..."
output = ""
errors = ""
exit_status = Open3.popen3("make test") do |stdin, stdout, stderr, wait_thr|
stdin.close
output << stdout.read
errors << stderr.read
wait_thr.value
end
puts output.yellow
if exit_status.success?
puts "Passed".green
else
puts errors
puts "Failed".red
end
}
end
View
@@ -1,43 +1,17 @@
SWIFT_BIN=$(shell which swift)
SWIFT_LINT=$(SWIFT_BIN)-lint
SWIFTC=swiftc
COPY=cp
REMOVE=rm
UNAME=$(shell uname)
ifeq ($(UNAME), Darwin)
XCODE=$(shell xcode-select -p)
SDK=$(XCODE)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
TARGET=x86_64-apple-macosx10.10
SWIFTC=swiftc -target $(TARGET) -sdk $(SDK) -Xlinker -all_load
COPY=sudo cp
REMOVE=sudo rm
endif
BUILD_DIR=.build/debug
LIBS=$(wildcard $(BUILD_DIR)/*.a)
LDFLAGS=$(foreach lib,$(LIBS),-Xlinker $(lib))
.PHONY: all clean build test install uninstall
.PHONY: all clean build test xcodegen
all: build
clean:
swift build --clean
swift package clean
build:
swift build
test: build $(BUILD_DIR)/test_runner
./$(BUILD_DIR)/test_runner
$(BUILD_DIR)/test_runner: Tests/*.swift Tests/rule/*.swift Tests/reporter/*.swift $(BUILD_DIR)/lint.a
$(SWIFTC) -o $@ Tests/*.swift Tests/rule/*.swift Tests/reporter/*.swift -I$(BUILD_DIR) -Xlinker $(BUILD_DIR)/Spectre.a $(LDFLAGS)
install:
$(COPY) $(BUILD_DIR)/swift-lint $(SWIFT_LINT)
test: build
swift test
uninstall:
$(REMOVE) $(SWIFT_LINT)
xcodegen:
swift package generate-xcodeproj --enable-code-coverage
View
@@ -0,0 +1,12 @@
{
"autoPin": true,
"pins": [
{
"package": "swift-ast",
"reason": null,
"repositoryURL": "https://github.com/yanagiba/swift-ast",
"version": "0.1.4"
}
],
"version": 1
}
View
@@ -1,5 +1,5 @@
/*
Copyright 2015 Ryuichi Saito, LLC
Copyright 2015-2017 Ryuichi Saito, LLC and the Yanagiba project contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -17,20 +17,43 @@
import PackageDescription
let package = Package(
name: "swift-lint",
targets: [
Target(
name: "swift-lint",
dependencies: [
"lint",
]
),
],
dependencies: [
.Package(url: "https://github.com/yanagiba/swift-ast", Version(0, 1, 3)),
.Package(url: "https://github.com/kylef/Commander", majorVersion: 0)
],
testDependencies: [
.Package(url: "https://github.com/kylef/Spectre.git", majorVersion: 0),
]
name: "swift-lint",
targets: [
Target(
name: "Lint"
),
Target(
name: "swift-lint",
dependencies: [
"Lint",
]
),
// MARK: Tests
Target(
name: "CanaryTests"
),
Target(
name: "LintTests",
dependencies: [
"Lint",
]
),
Target(
name: "RuleTests",
dependencies: [
"Lint",
]
),
Target(
name: "ReporterTests",
dependencies: [
"Lint",
]
),
],
dependencies: [
.Package(url: "https://github.com/yanagiba/swift-ast", Version(0, 1, 4)),
]
)
@@ -1,5 +1,5 @@
/*
Copyright 2015 Ryuichi Saito, LLC
Copyright 2017 Ryuichi Saito, LLC and the Yanagiba project contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,16 +14,10 @@
limitations under the License.
*/
specCanary()
import Source
import AST
specCorrection()
specDriver()
specRuleProtocol()
specASTVisitorRuleBase()
specSourceCodeRuleBase()
// spec reporters
specTextReporter()
// spec rules
specNoForceCastRule()
struct ASTContext {
let sourceFile: SourceFile
let topLevelDeclaration: TopLevelDeclaration
}
@@ -0,0 +1,35 @@
/*
Copyright 2017 Ryuichi Saito, LLC and the Yanagiba project contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import Source
class IssuePool {
static let shared = IssuePool()
public private(set) var issues: [Issue]
private init() {
issues = []
}
func add(issue: Issue) {
issues.append(issue)
}
func clearIssues() {
issues = []
}
}
@@ -0,0 +1,20 @@
/*
Copyright 2015 Ryuichi Saito, LLC and the Yanagiba project contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
class RuleBase {
var astContext: ASTContext?
var configurations: [String: Any]?
}
@@ -1,5 +1,5 @@
/*
Copyright 2015 Ryuichi Saito, LLC
Copyright 2015-2017 Ryuichi Saito, LLC and the Yanagiba project contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,28 +14,16 @@
limitations under the License.
*/
import ast
import parser
import source
import AST
class ASTVisitorRule {
var astContext: ASTContext!
var configurations: [String: AnyObject]?
func inspect(statement: Statement) {
// Do nothing here, waiting for subclass to override.
// TODO: This currently does not follow visitor pattern yet.
}
protocol ASTVisitorRule : Rule, ASTVisitor {
}
extension Rule where Self: ASTVisitorRule {
func inspect(ast: ASTContext, configurations: [String: AnyObject]? = nil) {
self.astContext = ast
self.configurations = configurations
extension ASTVisitorRule where Self: RuleBase {
func inspect(_ astContext: ASTContext, configurations: [String: Any]? = nil) {
self.astContext = astContext
self.configurations = configurations
let statements = astContext.topLevelDeclaration.statements
for statement in statements {
inspect(statement)
}
}
_ = try? traverse(astContext.topLevelDeclaration)
}
}
@@ -1,5 +1,5 @@
/*
Copyright 2015 Ryuichi Saito, LLC
Copyright 2015 Ryuichi Saito, LLC and the Yanagiba project contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,6 +14,6 @@
limitations under the License.
*/
public let SWIFT_LINT_VERSION = "0.1.1"
import Foundation
let EMIT_ISSUE_NOTIFICATION_NAME = "org.swiftlint.emit_issue_notification"
public let SWIFT_LINT_VERSION = "0.1.2"
Oops, something went wrong.

0 comments on commit b02737e

Please sign in to comment.