Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Release 1.6.0 #78

Merged
merged 74 commits into from
Feb 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
a775679
add travis.yml
Feb 9, 2016
3c61e6f
expose prepare- and iss-branches to travis
Feb 9, 2016
cfdf6c0
remove branch-filter for travis
Feb 9, 2016
45177e7
add `spec`-folder
Feb 9, 2016
3fca14d
add spec-skeleton
Feb 9, 2016
06ceab2
add default-failures
Feb 9, 2016
a3b69ed
remove .keep from `specs/`
Feb 9, 2016
0eef9d4
add mock-helper for `texteditor
Feb 9, 2016
e38af9a
fix test-scope to provideLinter()`
Feb 9, 2016
0065055
include node-path
Feb 9, 2016
bb1603d
include test-helpers
Feb 9, 2016
0f6f6b3
mock texteditor before each test
Feb 9, 2016
e36d53d
switch sudo-usage for travis-ci
Feb 9, 2016
207cd8a
imitating travis.ml from linter-erb
Feb 9, 2016
b6b96ff
using .travis.yml from atom
Feb 9, 2016
577d4bc
remove sudo-setting
Feb 9, 2016
4919a12
disable sandbox-dependency
Feb 9, 2016
e19d13f
add default-path to chrome-devel-sandbox
Feb 9, 2016
f2c3525
requiring sudo
Feb 9, 2016
7d41f9c
Revert "add default-path to chrome-devel-sandbox"
Feb 9, 2016
eb6735f
renamed spec-file
Feb 9, 2016
a219870
add language objective-c
Feb 9, 2016
16b1023
Revert "disable sandbox-dependency"
Feb 9, 2016
f0d473a
Revert "Revert "disable sandbox-dependency""
Feb 10, 2016
608d76b
removing objective-c for linux build
Feb 10, 2016
25f95ae
put language-key into matrix, add os-key
Feb 10, 2016
2ae6977
trying to fix miscombination of env-variables
Feb 10, 2016
f6285d8
trying to use global namespace
Feb 10, 2016
bff8301
Revert "trying to use global namespace"
Feb 10, 2016
52c1174
moved global env-vars away
Feb 10, 2016
0773dd8
changed matrix-order
Feb 10, 2016
9988e89
reintroduced apt packages
Feb 10, 2016
8be899e
move env-vars
Feb 11, 2016
ce0cd01
hook env vars directly into matrix
Feb 11, 2016
aa0471d
removed env-directive
Feb 11, 2016
218bcde
removed os-directive
Feb 11, 2016
df6af79
apply generic language
Feb 11, 2016
fbf41b5
decrease level of os-directive
Feb 11, 2016
66d155f
set matrix explicitly up
Feb 11, 2016
b1ba0c0
add chrome_devel_sandbox-env explicitly
Feb 11, 2016
efa49eb
Merge pull request #2 from florianb/issue-missing-sandbox
Feb 11, 2016
060aaaa
add linter-instantiation
Feb 11, 2016
3246ef3
add helper to generate a texteditor-stub
Feb 11, 2016
da7bfc5
add .java-fixtures for faulty, green and empty code
Feb 11, 2016
a47c9b4
add stderr-fixtures for a exec-stub
Feb 11, 2016
45c906e
add basic-specs
Feb 11, 2016
5573c11
fix #71 quick and dirty by decreasing the limit
Feb 11, 2016
354d82a
Merge pull request #3 from florianb/iss55
Feb 11, 2016
96b00d3
Merge remote-tracking branch 'AtomLinter/master' into prepare-1-6-0
Feb 18, 2016
0a9d6db
add config-setting for custom javac-options
Feb 18, 2016
f3b2629
add trim to javaExecutablePath
Feb 18, 2016
efa0fa8
add additionalOptions
Feb 18, 2016
6d3bf62
fix cp-initialization
Feb 18, 2016
16abeb0
fix check for cp-existence
Feb 18, 2016
cdd89c8
add use of additional options
Feb 18, 2016
3028872
add missing Xlint-option to example in config-description
Feb 18, 2016
f8cf9d7
Merge branch 'prepare-1-6-0' into iss65
Feb 18, 2016
0aabefc
inject additionalOptions
Feb 18, 2016
156fb69
Merge pull request #6 from florianb/iss35
Feb 18, 2016
2e2fe2b
Merge branch 'prepare-1-6-0' into iss65
Feb 18, 2016
c60f3c2
add additional descriptions
Feb 18, 2016
f7c967a
Merge pull request #7 from florianb/iss65
Feb 18, 2016
544affd
partially disable max_line_length of coffee lint
Feb 18, 2016
6ae5714
add quick fix to cut too many source-files off
Feb 18, 2016
a9294f9
Merge pull request #8 from florianb/iss58
Feb 19, 2016
8bdda6c
rename the specs to base-spec
Feb 19, 2016
0252810
refactor specs to rely on the atom-env
Feb 19, 2016
de2b5f4
add MIT license
Feb 19, 2016
6e4a021
bump version to 1.6.0
Feb 19, 2016
f916390
raise atom-dependency to 1.0.0
Feb 19, 2016
edbd066
Improved read
Feb 19, 2016
181cb79
changed misleading phrase
Feb 19, 2016
2d18893
fixed typos
Feb 19, 2016
f7cb3ba
fixed links
Feb 19, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
language: generic

notifications:
email:
on_success: never
on_failure: never

script: 'curl -s https://raw.githubusercontent.com/atom/ci/master/build-package.sh | sh'

git:
depth: 10

matrix:
include:
- os: linux
dist: trusty
sudo: required
language: cpp
env: ATOM_CHANNEL=stable APM_TEST_PACKAGES="" CHROME_DEVEL_SANDBOX=""
- os: linux
dist: trusty
sudo: required
language: cpp
env: ATOM_CHANNEL=beta APM_TEST_PACKAGES="" CHROME_DEVEL_SANDBOX=""
- os: osx
language: objective-c
env: ATOM_CHANNEL=stable APM_TEST_PACKAGES=""
- os: osx
language: objective-c
env: ATOM_CHANNEL=beta APM_TEST_PACKAGES=""


env:
global:
- APM_TEST_PACKAGES=""


addons:
apt:
packages:
- build-essential
- git
- libgnome-keyring-dev
- fakeroot
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Contributors of the AtomLinters/linter-javac Group

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
56 changes: 38 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,62 @@
# linter-javac

This package will lint your `.java` opened files in Atom through [javac](http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html).
This package will lint your opened `.java`-files on save, using [javac][javac-docs].

This package will ensure all dependencies are installed on activation.

## Installation

* Install [java](http://www.java.com/).
* `$ apm install linter-javac`
Ensure a working JDK is available in your environment (see FAQ) then enter the following on your command line:

apm install linter-javac

Or Atom ➔ Preferences... ➔ Packages ➔ Search for "linter-javac".


## Settings

You can configure linter-javac by editing `~/.atom/config.cson` (choose Open
Your Config in Atom menu):
You can configure linter-javac by using the GUI (recommended - the GUI offers a description and valid defaults) or by editing your `~/.atom/config.cson` (or Atom ➔ Open Your Config):

```coffeescript
"linter-javac":
# The path to javac. The default (javac) should work as long as you have it
# in your system PATH.
javaExecutablePath: "javac"
# Extra classpath. This will be appended to the classpath when executing javac.
classpath: ""
additionalClasspaths: "C:\Users\JohnDoe"
additionalJavacOptions: "-verbose -d C:\java-class-cache"
```
Example-Configuration, see our [Wiki][wiki] or the config-GUI for further information.

> To configure linter-javac on a per project-base, we currently encourage you using the [project-manager package][project-manager].


## Classpath

It is strongly recommended that you configure your classpath via a `.classpath`
file within your project (typically at the root). Simply create a file
named `.classpath` somewhere within your project (ideally at the root of
the project). The linter will search for this file by starting at the directory
of the file being compiled and then searching all parent directories within the
project. If you have more than one of these configuration files, it will use
the one that is "closest" to the file being compiled. Within `.classpath` place
only the classpath to be used for the project (nothing else). For example:
> The currently implemented `.classpath`-file format conflicts with the Eclipse-based file format. Therefore this implementation will be replaced in the far future.
We are aware that configuring classpath-information is the most important (and annoying) issue in linting source-files right - we are working hard to make our planned improvement imperceptible for you. We will keep you informed.

~~It is strongly recommended that you~~ You may configure your classpath via a `.classpath` file within your project (typically at the root). Simply create a file named `.classpath` somewhere within your project (ideally at the root of the project). The linter will search for this file by starting at the directory of the file being compiled and then searching all parent directories within the project. If you have more than one of these configuration files, it will use the one that is "closest" to the file being compiled. Within `.classpath` place only the classpath to be used for the project (nothing else). For example:

```java
.:./lib/junit.jar
```

This linter will execute `javac` within the directory of the `.classpath`
file, so relative paths can be considered to be relative to that file.


## Frequently Asked Questions

Please take a look into our [FAQs at our wiki][faqs].


### Can I help?

Yes please! Give us feedback, file bugs or just help us coding - join us on https://github.com/AtomLinter/linter-javac/issues and leave a note!


:gift_heart:



[javac-docs]: https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javac.html
[wiki]: https://github.com/AtomLinter/linter-javac/wiki
[project-manager]: https://atom.io/packages/project-manager
[faqs]: https://github.com/AtomLinter/linter-javac/wiki#frequently-asked-questions
89 changes: 80 additions & 9 deletions lib/init.coffee
Original file line number Diff line number Diff line change
@@ -1,30 +1,65 @@
{Directory, CompositeDisposable} = require 'atom'
_os = require 'os'
path = require 'path'
helpers = require 'atom-linter'
voucher = require 'voucher'
fs = require 'fs'
cpConfigFileName = '.classpath'

module.exports =
# coffeelint: disable=max_line_length
config:
javaExecutablePath:
javacExecutablePath:
type: 'string'
title: 'Path to the javac executable'
description: 'Path to the javac executable. This setting will be used to
call the java-compiler. The entered value should be immediately callable
on commandline. Example: `C:\\Program Files\\Java\\jdk1.6.0_16\\bin\\javac.exe`.
Keep in mind that placeholders like `~` do **not** work. If your
[path-variable](https://en.wikipedia.org/wiki/PATH_\(variable\))
is set properly it should not be necessary to change the default.'
default: 'javac'
classpath:
additionalClasspaths:
type: 'string'
title: "Extra classpath for javac"
description: 'Additional classpaths to be used (for the `-cp`-option)
when calling javac, separate multiple paths using the right
path-delimiter for your os (`:`/`;`).
Be aware that existing classpath-definitions from
the environment variable "CLASSPATH" will be merged into the argument,
as well as the content of your optional
[`.classpath`-files](https://atom.io/packages/linter-javac).
Example: `/path1:/path2` will become `javac -cp :/path1:/path2`.
Keep in mind that placeholders like `~` do **not** work.'
default: ''
additionalJavacOptions:
type: 'string'
default: ''
description: 'Your additional options will be inserted between
the javac-command and the sourcefiles. Example: `-d /root/class-cache`
will become `javac -Xlint:all -d /root/class-cache .../Test.java`
take a look to the
[javac-docs](http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javac.html)
for further information on valid options. Keep in mind that placeholders
like `~` do **not** work.'


activate: ->
require('atom-package-deps').install()
@subscriptions = new CompositeDisposable
@subscriptions.add atom.config.observe 'linter-javac.javaExecutablePath',
@subscriptions.add atom.config.observe 'linter-javac.javacExecutablePath',
(newValue) =>
@javaExecutablePath = newValue
@subscriptions.add atom.config.observe 'linter-javac.classpath',
@javaExecutablePath = newValue.trim()
@subscriptions.add atom.config.observe 'linter-javac.additionalClasspaths',
(newValue) =>
@classpath = newValue.trim()
@subscriptions.add atom.config.observe 'linter-javac.additionalJavacOptions',
(newValue) =>
trimmedValue = newValue.trim()
if trimmedValue
@additionalOptions = trimmedValue.split(/\s+/)
else
@additionalOptions = []

# coffeelint: enable=max_line_length

deactivate: ->
@subscriptions.dispose()
Expand All @@ -38,7 +73,7 @@ module.exports =
wd = path.dirname filePath
searchDir = @getProjectRootDir()
# Classpath
cp = null
cp = ''

# Find project config file if it exists.
cpConfig = @findClasspathConfig(wd)
Expand All @@ -62,9 +97,45 @@ module.exports =
.then (files) =>
# Arguments to javac
args = ['-Xlint:all']
args = args.concat(['-cp', cp]) if cp?
args = args.concat(['-cp', cp]) if cp

# add additional options to the args-array
if @additionalOptions.length > 0
args = args.concat @additionalOptions

args.push.apply(args, files)




# TODO: remove this quick fix
# count the size of expected execution-command
# see issue #58 for further details
cliLimit = if _os.platform() == 'win32' then 7900 else 130000
expectedCmdSize = @javaExecutablePath.length
sliceIndex = 0
for arg in args
expectedCmdSize++ # add prepending space
if (typeof arg) == 'string'
expectedCmdSize += arg.length
else
expectedCmdSize += arg.toString().length
if expectedCmdSize < cliLimit
sliceIndex++

if sliceIndex < (args.length - 1)
# coffeelint: disable=max_line_length
console.warn """
linter-javac: The lint-command is presumed to break the limit of #{cliLimit} characters on the #{_os.platform()}-platform.
Dropping #{args.length - sliceIndex} source files, as a result javac may not resolve all dependencies.
"""
# coffeelint: enable=max_line_length
args.push(filePath)
args = args.slice(0, sliceIndex)




# Execute javac
helpers.exec(@javaExecutablePath, args, {stream: 'stderr', cwd: wd})
.then (val) =>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "linter-javac",
"main": "./lib/init",
"version": "1.5.0",
"description": "Lint Java using javac",
"version": "1.6.0",
"description": "Lint Java on save, using javac.",
"repository": "https://github.com/AtomLinter/linter-javac",
"license": "MIT",
"engines": {
"atom": ">0.50.0"
"atom": ">1.0.0"
},
"dependencies": {
"atom-linter": "^4.5.0",
Expand Down
6 changes: 6 additions & 0 deletions spec/_spec-helpers.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Helpers for the specs of this plugin

# Generates a primitive stub of the atom-texteditor-object to provide a path
this.texteditorFactory = (texteditorPath) ->
getPath: () ->
texteditorPath
68 changes: 68 additions & 0 deletions spec/base-spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# This file contains all specs to ensure the base-functionality of
# this plugin.

_path = require 'path'


_helpers = require _path.join(__dirname, '_spec-helpers.coffee')


describe 'linter-javac', ->
beforeEach ->
#atom.workspace.destroyActivePaneItem
waitsForPromise ->
atom.packages.activatePackage 'linter-javac'
atom.packages.activatePackage 'language-java'



describe 'when using a faulty java-source file', ->
beforeEach ->
javaFile = _path.join(__dirname, 'fixtures', 'BrokenWorld.java')
waitsForPromise =>
atom.workspace.open(javaFile)
.then (whatever) =>
@texteditor = whatever
@linter = require(_path.join(__dirname, '..', 'lib', 'init.coffee'))
.provideLinter()

it 'returns at least 8 messages in the linter-message-object', ->
waitsForPromise( =>
@linter.lint(@texteditor).then( (messages) ->
expect(messages.length).toBeGreaterThan(7)
)
)



describe 'when using a correct java-source file', ->
beforeEach ->
javaFile = _path.join(__dirname, 'fixtures', 'HelloWorld.java')
waitsForPromise =>
atom.workspace.open(javaFile)
.then (whatever) =>
@texteditor = whatever
@linter = require(_path.join(__dirname, '..', 'lib', 'init.coffee'))
.provideLinter()

it 'returns an empty linter-message-object', ->
result = {}
expect(JSON.stringify(@linter.lint(@texteditor)))
.toEqual(JSON.stringify(result))



describe 'when using an empty java-source file', ->
beforeEach ->
javaFile = _path.join(__dirname, 'fixtures', 'EmptyWorld.java')
waitsForPromise =>
atom.workspace.open(javaFile)
.then (whatever) =>
@texteditor = whatever
@linter = require(_path.join(__dirname, '..', 'lib', 'init.coffee'))
.provideLinter()

it 'returns an empty linter-message-object', ->
result = {}
expect(JSON.stringify(@linter.lint(@texteditor)))
.toEqual(JSON.stringify(result))
12 changes: 12 additions & 0 deletions spec/fixtures/BrokenWorld.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*
This world is realistic.
*/
public class BrokenWorld

@SuppressWarnings({})
public static void main (String[ args)
{
/ This prints "Hello World!":
System.out.println("Hello World!")
}
}
Empty file added spec/fixtures/EmptyWorld.java
Empty file.
12 changes: 12 additions & 0 deletions spec/fixtures/HelloWorld.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
In this world, everything is okay!
*/
public class HelloWorld
{
@SuppressWarnings({})
public static void main (String[] args)
{
// This prints "Hello World!":
System.out.println("Hello World!");
}
}
Loading