├── .gitignore ├── Gemfile ├── Gemfile.lock ├── Guardfile ├── History.txt ├── LICENSE.txt ├── README.md ├── Rakefile ├── bin └── jrlint ├── jruby-lint.gemspec ├── lib └── jruby │ ├── lint.rb │ └── lint │ ├── ast.rb │ ├── checkers.rb │ ├── checkers │ ├── fork_exec.rb │ ├── gem.rb │ ├── gemspec.rb │ ├── nonatomic.rb │ ├── object_space.rb │ ├── system.rb │ └── thread_critical.rb │ ├── cli.rb │ ├── collectors.rb │ ├── collectors │ ├── bundler.rb │ ├── gemspec.rb │ ├── rake.rb │ └── ruby.rb │ ├── finding.rb │ ├── libraries.rb │ ├── project.rb │ ├── reporters.rb │ ├── reporters │ ├── html.rb │ ├── jruby-lint.html.erb │ └── text.rb │ └── version.rb └── spec ├── fixtures └── C-Extension-Alternatives.md ├── jruby └── lint │ ├── ast_spec.rb │ ├── checkers_spec.rb │ ├── collectors_spec.rb │ ├── finding_spec.rb │ ├── libraries_spec.rb │ ├── project_spec.rb │ ├── reporters_spec.rb │ └── version_spec.rb └── spec_helper.rb /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | .bundle 3 | Gemfile.lock 4 | pkg/* 5 | tmp 6 | lint-spec-report.html 7 | *.swp 8 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "http://rubygems.org" 2 | 3 | # Specify your gem's dependencies in jruby-lint.gemspec 4 | gemspec 5 | 6 | gem 'childprocess' 7 | gem 'guard' 8 | gem 'guard-rspec' 9 | gem 'growl' 10 | gem 'rb-fsevent' 11 | 12 | 13 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | jruby-lint (0.9.0) 5 | term-ansicolor 6 | 7 | GEM 8 | remote: http://rubygems.org/ 9 | specs: 10 | aruba (0.14.9) 11 | childprocess (>= 0.6.3, < 1.1.0) 12 | contracts (~> 0.9) 13 | cucumber (>= 1.3.19) 14 | ffi (~> 1.9) 15 | rspec-expectations (>= 2.99) 16 | thor (~> 0.19) 17 | backports (3.12.0) 18 | builder (3.2.3) 19 | childprocess (1.0.1) 20 | rake (< 13.0) 21 | coderay (1.1.2) 22 | contracts (0.16.0) 23 | cucumber (3.1.2) 24 | builder (>= 2.1.2) 25 | cucumber-core (~> 3.2.0) 26 | cucumber-expressions (~> 6.0.1) 27 | cucumber-wire (~> 0.0.1) 28 | diff-lcs (~> 1.3) 29 | gherkin (~> 5.1.0) 30 | multi_json (>= 1.7.5, < 2.0) 31 | multi_test (>= 0.1.2) 32 | cucumber-core (3.2.1) 33 | backports (>= 3.8.0) 34 | cucumber-tag_expressions (~> 1.1.0) 35 | gherkin (~> 5.0) 36 | cucumber-expressions (6.0.1) 37 | cucumber-tag_expressions (1.1.1) 38 | cucumber-wire (0.0.1) 39 | diff-lcs (1.3) 40 | ffi (1.10.0) 41 | ffi (1.10.0-java) 42 | formatador (0.2.5) 43 | gherkin (5.1.0) 44 | given_core (3.8.0) 45 | sorcerer (>= 0.3.7) 46 | growl (1.0.3) 47 | guard (2.15.0) 48 | formatador (>= 0.2.4) 49 | listen (>= 2.7, < 4.0) 50 | lumberjack (>= 1.0.12, < 2.0) 51 | nenv (~> 0.1) 52 | notiffany (~> 0.0) 53 | pry (>= 0.9.12) 54 | shellany (~> 0.0) 55 | thor (>= 0.18.1) 56 | guard-compat (1.2.1) 57 | guard-rspec (4.7.3) 58 | guard (~> 2.1) 59 | guard-compat (~> 1.1) 60 | rspec (>= 2.99.0, < 4.0) 61 | listen (3.1.5) 62 | rb-fsevent (~> 0.9, >= 0.9.4) 63 | rb-inotify (~> 0.9, >= 0.9.7) 64 | ruby_dep (~> 1.2) 65 | lumberjack (1.0.13) 66 | method_source (0.9.2) 67 | multi_json (1.13.1) 68 | multi_test (0.1.2) 69 | nenv (0.3.0) 70 | notiffany (0.1.1) 71 | nenv (~> 0.1) 72 | shellany (~> 0.0) 73 | pry (0.12.2) 74 | coderay (~> 1.1.0) 75 | method_source (~> 0.9.0) 76 | pry (0.12.2-java) 77 | coderay (~> 1.1.0) 78 | method_source (~> 0.9.0) 79 | spoon (~> 0.0) 80 | rake (12.3.3) 81 | rb-fsevent (0.10.3) 82 | rb-inotify (0.10.1) 83 | ffi (~> 1.0) 84 | rspec (3.8.0) 85 | rspec-core (~> 3.8.0) 86 | rspec-expectations (~> 3.8.0) 87 | rspec-mocks (~> 3.8.0) 88 | rspec-core (3.8.0) 89 | rspec-support (~> 3.8.0) 90 | rspec-expectations (3.8.2) 91 | diff-lcs (>= 1.2.0, < 2.0) 92 | rspec-support (~> 3.8.0) 93 | rspec-given (3.8.0) 94 | given_core (= 3.8.0) 95 | rspec (>= 2.14.0) 96 | rspec-mocks (3.8.0) 97 | diff-lcs (>= 1.2.0, < 2.0) 98 | rspec-support (~> 3.8.0) 99 | rspec-support (3.8.0) 100 | ruby_dep (1.5.0) 101 | shellany (0.0.1) 102 | sorcerer (1.0.2) 103 | spoon (0.0.6) 104 | ffi 105 | term-ansicolor (1.7.1) 106 | tins (~> 1.0) 107 | thor (0.20.3) 108 | tins (1.20.2) 109 | 110 | PLATFORMS 111 | java 112 | ruby 113 | 114 | DEPENDENCIES 115 | aruba 116 | childprocess 117 | growl 118 | guard 119 | guard-rspec 120 | jruby-lint! 121 | rake 122 | rb-fsevent 123 | rspec (>= 2.5) 124 | rspec-given 125 | 126 | BUNDLED WITH 127 | 1.17.3 128 | -------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | # Guardfile for JRuby-Lint 2 | # More info at https://github.com/guard/guard#readme 3 | 4 | guard 'rspec', :version => 2 do 5 | watch(%r{^spec/.+_spec\.rb}) 6 | watch(%r{^lib/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" } 7 | watch('spec/spec_helper.rb') { "spec" } 8 | end 9 | 10 | # Local Variables: 11 | # mode: ruby 12 | # End: 13 | -------------------------------------------------------------------------------- /History.txt: -------------------------------------------------------------------------------- 1 | === 0.4.1 / 2012/02/26 2 | 3 | - Add licensing information 4 | - Add nonatomic assignment operators (||=, &&= etc.) 5 | 6 | === 0.4.0 / 2012/11/1 7 | 8 | - Get failing specs fixed on 1.9 (JRuby 1.7.0) 9 | - Upgrade project gems 10 | 11 | === 0.3.1 / 2012/01/12 12 | 13 | - Allow versions of nokogiri >= 1.5.0.beta.4 (e.g., 1.5.0) 14 | - Enable adding tags from the command-line (e.g., 'debug') 15 | - Upgrade project gems: rake, rspec, childprocess 16 | 17 | === 0.3.0 / 2011-07-04 18 | 19 | - html reports 20 | 21 | === 0.2.0 / 2011-06-03 22 | 23 | - #system('ruby') and #timeout checkers, thanks Matthew Kirk (hexgnu)! 24 | - Update GitHub SSL cert chain 25 | 26 | === 0.1 / 2011-05-18 27 | 28 | - Birthday! 29 | 30 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | JRuby-Lint is Copyright (c) 2007-2013 The JRuby project, and is released 2 | under a tri EPL/GPL/LGPL license. You can use it, redistribute it 3 | and/or modify it under the terms of the: 4 | 5 | Eclipse Public License version 1.0 6 | GNU General Public License version 2 7 | GNU Lesser General Public License version 2.1 8 | 9 | 10 | The complete text of the Eclipse Public License is as follows: 11 | 12 | Eclipse Public License - v 1.0 13 | 14 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE 15 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION 16 | OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 17 | 18 | 1. DEFINITIONS 19 | 20 | "Contribution" means: 21 | 22 | a) in the case of the initial Contributor, the initial code and 23 | documentation distributed under this Agreement, and 24 | 25 | b) in the case of each subsequent Contributor: 26 | 27 | i) changes to the Program, and 28 | 29 | ii) additions to the Program; 30 | where such changes and/or additions to the Program 31 | originate from and are distributed by that particular 32 | Contributor. A Contribution 'originates' from a 33 | Contributor if it was added to the Program by such 34 | Contributor itself or anyone acting on such 35 | Contributor's behalf. Contributions do not include 36 | additions to the Program which: (i) are separate modules 37 | of software distributed in conjunction with the Program 38 | under their own license agreement, and (ii) are not 39 | derivative works of the Program. 40 | 41 | "Contributor" means any person or entity that distributes the Program. 42 | 43 | "Licensed Patents" mean patent claims licensable by a Contributor 44 | which are necessarily infringed by the use or sale of its 45 | Contribution alone or when combined with the Program. 46 | 47 | "Program" means the Contributions distributed in accordance with 48 | this Agreement. 49 | 50 | "Recipient" means anyone who receives the Program under this 51 | Agreement, including all Contributors. 52 | 53 | 2. GRANT OF RIGHTS 54 | 55 | a) Subject to the terms of this Agreement, each Contributor 56 | hereby grants Recipient a non-exclusive, worldwide, 57 | royalty-free copyright license to reproduce, prepare 58 | derivative works of, publicly display, publicly perform, 59 | distribute and sublicense the Contribution of such 60 | Contributor, if any, and such derivative works, in source 61 | code and object code form. 62 | 63 | b) Subject to the terms of this Agreement, each Contributor 64 | hereby grants Recipient a non-exclusive, worldwide, 65 | royalty-free patent license under Licensed Patents to make, 66 | use, sell, offer to sell, import and otherwise transfer the 67 | Contribution of such Contributor, if any, in source code and 68 | object code form. This patent license shall apply to the 69 | combination of the Contribution and the Program if, at the 70 | time the Contribution is added by the Contributor, such 71 | addition of the Contribution causes such combination to be 72 | covered by the Licensed Patents. The patent license shall not 73 | apply to any other combinations which include the 74 | Contribution. No hardware per se is licensed hereunder. 75 | 76 | c) Recipient understands that although each Contributor grants 77 | the licenses to its Contributions set forth herein, no 78 | assurances are provided by any Contributor that the Program 79 | does not infringe the patent or other intellectual property 80 | rights of any other entity. Each Contributor disclaims any 81 | liability to Recipient for claims brought by any other entity 82 | based on infringement of intellectual property rights or 83 | otherwise. As a condition to exercising the rights and 84 | licenses granted hereunder, each Recipient hereby assumes 85 | sole responsibility to secure any other intellectual property 86 | rights needed, if any. For example, if a third party patent 87 | license is required to allow Recipient to distribute the 88 | Program, it is Recipient's responsibility to acquire that 89 | license before distributing the Program. 90 | 91 | d) Each Contributor represents that to its knowledge it has 92 | sufficient copyright rights in its Contribution, if any, to 93 | grant the copyright license set forth in this Agreement. 94 | 95 | 3. REQUIREMENTS 96 | 97 | A Contributor may choose to distribute the Program in object code 98 | form under its own license agreement, provided that: 99 | 100 | a) it complies with the terms and conditions of this Agreement; and 101 | 102 | b) its license agreement: 103 | 104 | i) effectively disclaims on behalf of all Contributors all 105 | warranties and conditions, express and implied, including 106 | warranties or conditions of title and non-infringement, 107 | and implied warranties or conditions of merchantability 108 | and fitness for a particular purpose; 109 | 110 | ii) effectively excludes on behalf of all Contributors all 111 | liability for damages, including direct, indirect, 112 | special, incidental and consequential damages, such as 113 | lost profits; 114 | 115 | iii) states that any provisions which differ from this 116 | Agreement are offered by that Contributor alone and not 117 | by any other party; and 118 | 119 | iv) states that source code for the Program is available 120 | from such Contributor, and informs licensees how to 121 | obtain it in a reasonable manner on or through a medium 122 | customarily used for software exchange. 123 | 124 | When the Program is made available in source code form: 125 | 126 | a) it must be made available under this Agreement; and 127 | 128 | b) a copy of this Agreement must be included with each copy of 129 | the Program. 130 | 131 | Contributors may not remove or alter any copyright notices contained 132 | within the Program. 133 | 134 | Each Contributor must identify itself as the originator of its 135 | Contribution, if any, in a manner that reasonably allows subsequent 136 | Recipients to identify the originator of the Contribution. 137 | 138 | 4. COMMERCIAL DISTRIBUTION 139 | 140 | Commercial distributors of software may accept certain 141 | responsibilities with respect to end users, business partners and 142 | the like. While this license is intended to facilitate the 143 | commercial use of the Program, the Contributor who includes the 144 | Program in a commercial product offering should do so in a manner 145 | which does not create potential liability for other Contributors. 146 | Therefore, if a Contributor includes the Program in a commercial 147 | product offering, such Contributor ("Commercial Contributor") hereby 148 | agrees to defend and indemnify every other Contributor ("Indemnified 149 | Contributor") against any losses, damages and costs (collectively 150 | "Losses") arising from claims, lawsuits and other legal actions 151 | brought by a third party against the Indemnified Contributor to the 152 | extent caused by the acts or omissions of such Commercial 153 | Contributor in connection with its distribution of the Program in a 154 | commercial product offering. The obligations in this section do not 155 | apply to any claims or Losses relating to any actual or alleged 156 | intellectual property infringement. In order to qualify, an 157 | Indemnified Contributor must: a) promptly notify the Commercial 158 | Contributor in writing of such claim, and b) allow the Commercial 159 | Contributor to control, and cooperate with the Commercial 160 | Contributor in, the defense and any related settlement negotiations. 161 | The Indemnified Contributor may participate in any such claim at its 162 | own expense. 163 | 164 | For example, a Contributor might include the Program in a commercial 165 | product offering, Product X. That Contributor is then a Commercial 166 | Contributor. If that Commercial Contributor then makes performance 167 | claims, or offers warranties related to Product X, those performance 168 | claims and warranties are such Commercial Contributor's 169 | responsibility alone. Under this section, the Commercial Contributor 170 | would have to defend claims against the other Contributors related 171 | to those performance claims and warranties, and if a court requires 172 | any other Contributor to pay any damages as a result, the Commercial 173 | Contributor must pay those damages. 174 | 175 | 5. NO WARRANTY 176 | 177 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS 178 | PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 179 | ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, 180 | ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 181 | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient 182 | is solely responsible for determining the appropriateness of using 183 | and distributing the Program and assumes all risks associated with 184 | its exercise of rights under this Agreement , including but not 185 | limited to the risks and costs of program errors, compliance with 186 | applicable laws, damage to or loss of data, programs or equipment, 187 | and unavailability or interruption of operations. 188 | 189 | 6. DISCLAIMER OF LIABILITY 190 | 191 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT 192 | NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, 193 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 194 | (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON 195 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 196 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 197 | THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS 198 | GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 199 | DAMAGES. 200 | 201 | 7. GENERAL 202 | 203 | If any provision of this Agreement is invalid or unenforceable under 204 | applicable law, it shall not affect the validity or enforceability 205 | of the remainder of the terms of this Agreement, and without further 206 | action by the parties hereto, such provision shall be reformed to 207 | the minimum extent necessary to make such provision valid and 208 | enforceable. 209 | 210 | If Recipient institutes patent litigation against any entity 211 | (including a cross-claim or counterclaim in a lawsuit) alleging that 212 | the Program itself (excluding combinations of the Program with other 213 | software or hardware) infringes such Recipient's patent(s), then 214 | such Recipient's rights granted under Section 2(b) shall terminate 215 | as of the date such litigation is filed. 216 | 217 | All Recipient's rights under this Agreement shall terminate if it 218 | fails to comply with any of the material terms or conditions of this 219 | Agreement and does not cure such failure in a reasonable period of 220 | time after becoming aware of such noncompliance. If all Recipient's 221 | rights under this Agreement terminate, Recipient agrees to cease use 222 | and distribution of the Program as soon as reasonably practicable. 223 | However, Recipient's obligations under this Agreement and any 224 | licenses granted by Recipient relating to the Program shall continue 225 | and survive. 226 | 227 | Everyone is permitted to copy and distribute copies of this 228 | Agreement, but in order to avoid inconsistency the Agreement is 229 | copyrighted and may only be modified in the following manner. The 230 | Agreement Steward reserves the right to publish new versions 231 | (including revisions) of this Agreement from time to time. No one 232 | other than the Agreement Steward has the right to modify this 233 | Agreement. The Eclipse Foundation is the initial Agreement Steward. 234 | The Eclipse Foundation may assign the responsibility to serve as the 235 | Agreement Steward to a suitable separate entity. Each new version of 236 | the Agreement will be given a distinguishing version number. The 237 | Program (including Contributions) may always be distributed subject 238 | to the version of the Agreement under which it was received. In 239 | addition, after a new version of the Agreement is published, 240 | Contributor may elect to distribute the Program (including its 241 | Contributions) under the new version. Except as expressly stated in 242 | Sections 2(a) and 2(b) above, Recipient receives no rights or 243 | licenses to the intellectual property of any Contributor under this 244 | Agreement, whether expressly, by implication, estoppel or otherwise. 245 | All rights in the Program not expressly granted under this Agreement 246 | are reserved. 247 | 248 | This Agreement is governed by the laws of the State of New York and 249 | the intellectual property laws of the United States of America. No 250 | party to this Agreement will bring a legal action under this 251 | Agreement more than one year after the cause of action arose. Each 252 | party waives its rights to a jury trial in any resulting litigation. 253 | 254 | 255 | The complete text of the GNU General Public License v2 is as follows: 256 | 257 | GNU GENERAL PUBLIC LICENSE 258 | Version 2, June 1991 259 | 260 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 261 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 262 | Everyone is permitted to copy and distribute verbatim copies 263 | of this license document, but changing it is not allowed. 264 | 265 | Preamble 266 | 267 | The licenses for most software are designed to take away your 268 | freedom to share and change it. By contrast, the GNU General Public 269 | License is intended to guarantee your freedom to share and change free 270 | software--to make sure the software is free for all its users. This 271 | General Public License applies to most of the Free Software 272 | Foundation's software and to any other program whose authors commit to 273 | using it. (Some other Free Software Foundation software is covered by 274 | the GNU Library General Public License instead.) You can apply it to 275 | your programs, too. 276 | 277 | When we speak of free software, we are referring to freedom, not 278 | price. Our General Public Licenses are designed to make sure that you 279 | have the freedom to distribute copies of free software (and charge for 280 | this service if you wish), that you receive source code or can get it 281 | if you want it, that you can change the software or use pieces of it 282 | in new free programs; and that you know you can do these things. 283 | 284 | To protect your rights, we need to make restrictions that forbid 285 | anyone to deny you these rights or to ask you to surrender the rights. 286 | These restrictions translate to certain responsibilities for you if you 287 | distribute copies of the software, or if you modify it. 288 | 289 | For example, if you distribute copies of such a program, whether 290 | gratis or for a fee, you must give the recipients all the rights that 291 | you have. You must make sure that they, too, receive or can get the 292 | source code. And you must show them these terms so they know their 293 | rights. 294 | 295 | We protect your rights with two steps: (1) copyright the software, and 296 | (2) offer you this license which gives you legal permission to copy, 297 | distribute and/or modify the software. 298 | 299 | Also, for each author's protection and ours, we want to make certain 300 | that everyone understands that there is no warranty for this free 301 | software. If the software is modified by someone else and passed on, we 302 | want its recipients to know that what they have is not the original, so 303 | that any problems introduced by others will not reflect on the original 304 | authors' reputations. 305 | 306 | Finally, any free program is threatened constantly by software 307 | patents. We wish to avoid the danger that redistributors of a free 308 | program will individually obtain patent licenses, in effect making the 309 | program proprietary. To prevent this, we have made it clear that any 310 | patent must be licensed for everyone's free use or not licensed at all. 311 | 312 | The precise terms and conditions for copying, distribution and 313 | modification follow. 314 | 315 | GNU GENERAL PUBLIC LICENSE 316 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 317 | 318 | 0. This License applies to any program or other work which contains 319 | a notice placed by the copyright holder saying it may be distributed 320 | under the terms of this General Public License. The "Program", below, 321 | refers to any such program or work, and a "work based on the Program" 322 | means either the Program or any derivative work under copyright law: 323 | that is to say, a work containing the Program or a portion of it, 324 | either verbatim or with modifications and/or translated into another 325 | language. (Hereinafter, translation is included without limitation in 326 | the term "modification".) Each licensee is addressed as "you". 327 | 328 | Activities other than copying, distribution and modification are not 329 | covered by this License; they are outside its scope. The act of 330 | running the Program is not restricted, and the output from the Program 331 | is covered only if its contents constitute a work based on the 332 | Program (independent of having been made by running the Program). 333 | Whether that is true depends on what the Program does. 334 | 335 | 1. You may copy and distribute verbatim copies of the Program's 336 | source code as you receive it, in any medium, provided that you 337 | conspicuously and appropriately publish on each copy an appropriate 338 | copyright notice and disclaimer of warranty; keep intact all the 339 | notices that refer to this License and to the absence of any warranty; 340 | and give any other recipients of the Program a copy of this License 341 | along with the Program. 342 | 343 | You may charge a fee for the physical act of transferring a copy, and 344 | you may at your option offer warranty protection in exchange for a fee. 345 | 346 | 2. You may modify your copy or copies of the Program or any portion 347 | of it, thus forming a work based on the Program, and copy and 348 | distribute such modifications or work under the terms of Section 1 349 | above, provided that you also meet all of these conditions: 350 | 351 | a) You must cause the modified files to carry prominent notices 352 | stating that you changed the files and the date of any change. 353 | 354 | b) You must cause any work that you distribute or publish, that in 355 | whole or in part contains or is derived from the Program or any 356 | part thereof, to be licensed as a whole at no charge to all third 357 | parties under the terms of this License. 358 | 359 | c) If the modified program normally reads commands interactively 360 | when run, you must cause it, when started running for such 361 | interactive use in the most ordinary way, to print or display an 362 | announcement including an appropriate copyright notice and a 363 | notice that there is no warranty (or else, saying that you provide 364 | a warranty) and that users may redistribute the program under 365 | these conditions, and telling the user how to view a copy of this 366 | License. (Exception: if the Program itself is interactive but 367 | does not normally print such an announcement, your work based on 368 | the Program is not required to print an announcement.) 369 | 370 | These requirements apply to the modified work as a whole. If 371 | identifiable sections of that work are not derived from the Program, 372 | and can be reasonably considered independent and separate works in 373 | themselves, then this License, and its terms, do not apply to those 374 | sections when you distribute them as separate works. But when you 375 | distribute the same sections as part of a whole which is a work based 376 | on the Program, the distribution of the whole must be on the terms of 377 | this License, whose permissions for other licensees extend to the 378 | entire whole, and thus to each and every part regardless of who wrote it. 379 | 380 | Thus, it is not the intent of this section to claim rights or contest 381 | your rights to work written entirely by you; rather, the intent is to 382 | exercise the right to control the distribution of derivative or 383 | collective works based on the Program. 384 | 385 | In addition, mere aggregation of another work not based on the Program 386 | with the Program (or with a work based on the Program) on a volume of 387 | a storage or distribution medium does not bring the other work under 388 | the scope of this License. 389 | 390 | 3. You may copy and distribute the Program (or a work based on it, 391 | under Section 2) in object code or executable form under the terms of 392 | Sections 1 and 2 above provided that you also do one of the following: 393 | 394 | a) Accompany it with the complete corresponding machine-readable 395 | source code, which must be distributed under the terms of Sections 396 | 1 and 2 above on a medium customarily used for software interchange; or, 397 | 398 | b) Accompany it with a written offer, valid for at least three 399 | years, to give any third party, for a charge no more than your 400 | cost of physically performing source distribution, a complete 401 | machine-readable copy of the corresponding source code, to be 402 | distributed under the terms of Sections 1 and 2 above on a medium 403 | customarily used for software interchange; or, 404 | 405 | c) Accompany it with the information you received as to the offer 406 | to distribute corresponding source code. (This alternative is 407 | allowed only for noncommercial distribution and only if you 408 | received the program in object code or executable form with such 409 | an offer, in accord with Subsection b above.) 410 | 411 | The source code for a work means the preferred form of the work for 412 | making modifications to it. For an executable work, complete source 413 | code means all the source code for all modules it contains, plus any 414 | associated interface definition files, plus the scripts used to 415 | control compilation and installation of the executable. However, as a 416 | special exception, the source code distributed need not include 417 | anything that is normally distributed (in either source or binary 418 | form) with the major components (compiler, kernel, and so on) of the 419 | operating system on which the executable runs, unless that component 420 | itself accompanies the executable. 421 | 422 | If distribution of executable or object code is made by offering 423 | access to copy from a designated place, then offering equivalent 424 | access to copy the source code from the same place counts as 425 | distribution of the source code, even though third parties are not 426 | compelled to copy the source along with the object code. 427 | 428 | 4. You may not copy, modify, sublicense, or distribute the Program 429 | except as expressly provided under this License. Any attempt 430 | otherwise to copy, modify, sublicense or distribute the Program is 431 | void, and will automatically terminate your rights under this License. 432 | However, parties who have received copies, or rights, from you under 433 | this License will not have their licenses terminated so long as such 434 | parties remain in full compliance. 435 | 436 | 5. You are not required to accept this License, since you have not 437 | signed it. However, nothing else grants you permission to modify or 438 | distribute the Program or its derivative works. These actions are 439 | prohibited by law if you do not accept this License. Therefore, by 440 | modifying or distributing the Program (or any work based on the 441 | Program), you indicate your acceptance of this License to do so, and 442 | all its terms and conditions for copying, distributing or modifying 443 | the Program or works based on it. 444 | 445 | 6. Each time you redistribute the Program (or any work based on the 446 | Program), the recipient automatically receives a license from the 447 | original licensor to copy, distribute or modify the Program subject to 448 | these terms and conditions. You may not impose any further 449 | restrictions on the recipients' exercise of the rights granted herein. 450 | You are not responsible for enforcing compliance by third parties to 451 | this License. 452 | 453 | 7. If, as a consequence of a court judgment or allegation of patent 454 | infringement or for any other reason (not limited to patent issues), 455 | conditions are imposed on you (whether by court order, agreement or 456 | otherwise) that contradict the conditions of this License, they do not 457 | excuse you from the conditions of this License. If you cannot 458 | distribute so as to satisfy simultaneously your obligations under this 459 | License and any other pertinent obligations, then as a consequence you 460 | may not distribute the Program at all. For example, if a patent 461 | license would not permit royalty-free redistribution of the Program by 462 | all those who receive copies directly or indirectly through you, then 463 | the only way you could satisfy both it and this License would be to 464 | refrain entirely from distribution of the Program. 465 | 466 | If any portion of this section is held invalid or unenforceable under 467 | any particular circumstance, the balance of the section is intended to 468 | apply and the section as a whole is intended to apply in other 469 | circumstances. 470 | 471 | It is not the purpose of this section to induce you to infringe any 472 | patents or other property right claims or to contest validity of any 473 | such claims; this section has the sole purpose of protecting the 474 | integrity of the free software distribution system, which is 475 | implemented by public license practices. Many people have made 476 | generous contributions to the wide range of software distributed 477 | through that system in reliance on consistent application of that 478 | system; it is up to the author/donor to decide if he or she is willing 479 | to distribute software through any other system and a licensee cannot 480 | impose that choice. 481 | 482 | This section is intended to make thoroughly clear what is believed to 483 | be a consequence of the rest of this License. 484 | 485 | 8. If the distribution and/or use of the Program is restricted in 486 | certain countries either by patents or by copyrighted interfaces, the 487 | original copyright holder who places the Program under this License 488 | may add an explicit geographical distribution limitation excluding 489 | those countries, so that distribution is permitted only in or among 490 | countries not thus excluded. In such case, this License incorporates 491 | the limitation as if written in the body of this License. 492 | 493 | 9. The Free Software Foundation may publish revised and/or new versions 494 | of the General Public License from time to time. Such new versions will 495 | be similar in spirit to the present version, but may differ in detail to 496 | address new problems or concerns. 497 | 498 | Each version is given a distinguishing version number. If the Program 499 | specifies a version number of this License which applies to it and "any 500 | later version", you have the option of following the terms and conditions 501 | either of that version or of any later version published by the Free 502 | Software Foundation. If the Program does not specify a version number of 503 | this License, you may choose any version ever published by the Free Software 504 | Foundation. 505 | 506 | 10. If you wish to incorporate parts of the Program into other free 507 | programs whose distribution conditions are different, write to the author 508 | to ask for permission. For software which is copyrighted by the Free 509 | Software Foundation, write to the Free Software Foundation; we sometimes 510 | make exceptions for this. Our decision will be guided by the two goals 511 | of preserving the free status of all derivatives of our free software and 512 | of promoting the sharing and reuse of software generally. 513 | 514 | NO WARRANTY 515 | 516 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 517 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 518 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 519 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 520 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 521 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 522 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 523 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 524 | REPAIR OR CORRECTION. 525 | 526 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 527 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 528 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 529 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 530 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 531 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 532 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 533 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 534 | POSSIBILITY OF SUCH DAMAGES. 535 | 536 | END OF TERMS AND CONDITIONS 537 | 538 | The complete text of the GNU Lesser General Public License 2.1 is as follows: 539 | 540 | GNU LESSER GENERAL PUBLIC LICENSE 541 | Version 2.1, February 1999 542 | 543 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 544 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 545 | Everyone is permitted to copy and distribute verbatim copies 546 | of this license document, but changing it is not allowed. 547 | 548 | [This is the first released version of the Lesser GPL. It also counts 549 | as the successor of the GNU Library Public License, version 2, hence 550 | the version number 2.1.] 551 | 552 | Preamble 553 | 554 | The licenses for most software are designed to take away your 555 | freedom to share and change it. By contrast, the GNU General Public 556 | Licenses are intended to guarantee your freedom to share and change 557 | free software--to make sure the software is free for all its users. 558 | 559 | This license, the Lesser General Public License, applies to some 560 | specially designated software packages--typically libraries--of the 561 | Free Software Foundation and other authors who decide to use it. You 562 | can use it too, but we suggest you first think carefully about whether 563 | this license or the ordinary General Public License is the better 564 | strategy to use in any particular case, based on the explanations below. 565 | 566 | When we speak of free software, we are referring to freedom of use, 567 | not price. Our General Public Licenses are designed to make sure that 568 | you have the freedom to distribute copies of free software (and charge 569 | for this service if you wish); that you receive source code or can get 570 | it if you want it; that you can change the software and use pieces of 571 | it in new free programs; and that you are informed that you can do 572 | these things. 573 | 574 | To protect your rights, we need to make restrictions that forbid 575 | distributors to deny you these rights or to ask you to surrender these 576 | rights. These restrictions translate to certain responsibilities for 577 | you if you distribute copies of the library or if you modify it. 578 | 579 | For example, if you distribute copies of the library, whether gratis 580 | or for a fee, you must give the recipients all the rights that we gave 581 | you. You must make sure that they, too, receive or can get the source 582 | code. If you link other code with the library, you must provide 583 | complete object files to the recipients, so that they can relink them 584 | with the library after making changes to the library and recompiling 585 | it. And you must show them these terms so they know their rights. 586 | 587 | We protect your rights with a two-step method: (1) we copyright the 588 | library, and (2) we offer you this license, which gives you legal 589 | permission to copy, distribute and/or modify the library. 590 | 591 | To protect each distributor, we want to make it very clear that 592 | there is no warranty for the free library. Also, if the library is 593 | modified by someone else and passed on, the recipients should know 594 | that what they have is not the original version, so that the original 595 | author's reputation will not be affected by problems that might be 596 | introduced by others. 597 | 598 | Finally, software patents pose a constant threat to the existence of 599 | any free program. We wish to make sure that a company cannot 600 | effectively restrict the users of a free program by obtaining a 601 | restrictive license from a patent holder. Therefore, we insist that 602 | any patent license obtained for a version of the library must be 603 | consistent with the full freedom of use specified in this license. 604 | 605 | Most GNU software, including some libraries, is covered by the 606 | ordinary GNU General Public License. This license, the GNU Lesser 607 | General Public License, applies to certain designated libraries, and 608 | is quite different from the ordinary General Public License. We use 609 | this license for certain libraries in order to permit linking those 610 | libraries into non-free programs. 611 | 612 | When a program is linked with a library, whether statically or using 613 | a shared library, the combination of the two is legally speaking a 614 | combined work, a derivative of the original library. The ordinary 615 | General Public License therefore permits such linking only if the 616 | entire combination fits its criteria of freedom. The Lesser General 617 | Public License permits more lax criteria for linking other code with 618 | the library. 619 | 620 | We call this license the "Lesser" General Public License because it 621 | does Less to protect the user's freedom than the ordinary General 622 | Public License. It also provides other free software developers Less 623 | of an advantage over competing non-free programs. These disadvantages 624 | are the reason we use the ordinary General Public License for many 625 | libraries. However, the Lesser license provides advantages in certain 626 | special circumstances. 627 | 628 | For example, on rare occasions, there may be a special need to 629 | encourage the widest possible use of a certain library, so that it becomes 630 | a de-facto standard. To achieve this, non-free programs must be 631 | allowed to use the library. A more frequent case is that a free 632 | library does the same job as widely used non-free libraries. In this 633 | case, there is little to gain by limiting the free library to free 634 | software only, so we use the Lesser General Public License. 635 | 636 | In other cases, permission to use a particular library in non-free 637 | programs enables a greater number of people to use a large body of 638 | free software. For example, permission to use the GNU C Library in 639 | non-free programs enables many more people to use the whole GNU 640 | operating system, as well as its variant, the GNU/Linux operating 641 | system. 642 | 643 | Although the Lesser General Public License is Less protective of the 644 | users' freedom, it does ensure that the user of a program that is 645 | linked with the Library has the freedom and the wherewithal to run 646 | that program using a modified version of the Library. 647 | 648 | The precise terms and conditions for copying, distribution and 649 | modification follow. Pay close attention to the difference between a 650 | "work based on the library" and a "work that uses the library". The 651 | former contains code derived from the library, whereas the latter must 652 | be combined with the library in order to run. 653 | 654 | GNU LESSER GENERAL PUBLIC LICENSE 655 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 656 | 657 | 0. This License Agreement applies to any software library or other 658 | program which contains a notice placed by the copyright holder or 659 | other authorized party saying it may be distributed under the terms of 660 | this Lesser General Public License (also called "this License"). 661 | Each licensee is addressed as "you". 662 | 663 | A "library" means a collection of software functions and/or data 664 | prepared so as to be conveniently linked with application programs 665 | (which use some of those functions and data) to form executables. 666 | 667 | The "Library", below, refers to any such software library or work 668 | which has been distributed under these terms. A "work based on the 669 | Library" means either the Library or any derivative work under 670 | copyright law: that is to say, a work containing the Library or a 671 | portion of it, either verbatim or with modifications and/or translated 672 | straightforwardly into another language. (Hereinafter, translation is 673 | included without limitation in the term "modification".) 674 | 675 | "Source code" for a work means the preferred form of the work for 676 | making modifications to it. For a library, complete source code means 677 | all the source code for all modules it contains, plus any associated 678 | interface definition files, plus the scripts used to control compilation 679 | and installation of the library. 680 | 681 | Activities other than copying, distribution and modification are not 682 | covered by this License; they are outside its scope. The act of 683 | running a program using the Library is not restricted, and output from 684 | such a program is covered only if its contents constitute a work based 685 | on the Library (independent of the use of the Library in a tool for 686 | writing it). Whether that is true depends on what the Library does 687 | and what the program that uses the Library does. 688 | 689 | 1. You may copy and distribute verbatim copies of the Library's 690 | complete source code as you receive it, in any medium, provided that 691 | you conspicuously and appropriately publish on each copy an 692 | appropriate copyright notice and disclaimer of warranty; keep intact 693 | all the notices that refer to this License and to the absence of any 694 | warranty; and distribute a copy of this License along with the 695 | Library. 696 | 697 | You may charge a fee for the physical act of transferring a copy, 698 | and you may at your option offer warranty protection in exchange for a 699 | fee. 700 | 701 | 2. You may modify your copy or copies of the Library or any portion 702 | of it, thus forming a work based on the Library, and copy and 703 | distribute such modifications or work under the terms of Section 1 704 | above, provided that you also meet all of these conditions: 705 | 706 | a) The modified work must itself be a software library. 707 | 708 | b) You must cause the files modified to carry prominent notices 709 | stating that you changed the files and the date of any change. 710 | 711 | c) You must cause the whole of the work to be licensed at no 712 | charge to all third parties under the terms of this License. 713 | 714 | d) If a facility in the modified Library refers to a function or a 715 | table of data to be supplied by an application program that uses 716 | the facility, other than as an argument passed when the facility 717 | is invoked, then you must make a good faith effort to ensure that, 718 | in the event an application does not supply such function or 719 | table, the facility still operates, and performs whatever part of 720 | its purpose remains meaningful. 721 | 722 | (For example, a function in a library to compute square roots has 723 | a purpose that is entirely well-defined independent of the 724 | application. Therefore, Subsection 2d requires that any 725 | application-supplied function or table used by this function must 726 | be optional: if the application does not supply it, the square 727 | root function must still compute square roots.) 728 | 729 | These requirements apply to the modified work as a whole. If 730 | identifiable sections of that work are not derived from the Library, 731 | and can be reasonably considered independent and separate works in 732 | themselves, then this License, and its terms, do not apply to those 733 | sections when you distribute them as separate works. But when you 734 | distribute the same sections as part of a whole which is a work based 735 | on the Library, the distribution of the whole must be on the terms of 736 | this License, whose permissions for other licensees extend to the 737 | entire whole, and thus to each and every part regardless of who wrote 738 | it. 739 | 740 | Thus, it is not the intent of this section to claim rights or contest 741 | your rights to work written entirely by you; rather, the intent is to 742 | exercise the right to control the distribution of derivative or 743 | collective works based on the Library. 744 | 745 | In addition, mere aggregation of another work not based on the Library 746 | with the Library (or with a work based on the Library) on a volume of 747 | a storage or distribution medium does not bring the other work under 748 | the scope of this License. 749 | 750 | 3. You may opt to apply the terms of the ordinary GNU General Public 751 | License instead of this License to a given copy of the Library. To do 752 | this, you must alter all the notices that refer to this License, so 753 | that they refer to the ordinary GNU General Public License, version 2, 754 | instead of to this License. (If a newer version than version 2 of the 755 | ordinary GNU General Public License has appeared, then you can specify 756 | that version instead if you wish.) Do not make any other change in 757 | these notices. 758 | 759 | Once this change is made in a given copy, it is irreversible for 760 | that copy, so the ordinary GNU General Public License applies to all 761 | subsequent copies and derivative works made from that copy. 762 | 763 | This option is useful when you wish to copy part of the code of 764 | the Library into a program that is not a library. 765 | 766 | 4. You may copy and distribute the Library (or a portion or 767 | derivative of it, under Section 2) in object code or executable form 768 | under the terms of Sections 1 and 2 above provided that you accompany 769 | it with the complete corresponding machine-readable source code, which 770 | must be distributed under the terms of Sections 1 and 2 above on a 771 | medium customarily used for software interchange. 772 | 773 | If distribution of object code is made by offering access to copy 774 | from a designated place, then offering equivalent access to copy the 775 | source code from the same place satisfies the requirement to 776 | distribute the source code, even though third parties are not 777 | compelled to copy the source along with the object code. 778 | 779 | 5. A program that contains no derivative of any portion of the 780 | Library, but is designed to work with the Library by being compiled or 781 | linked with it, is called a "work that uses the Library". Such a 782 | work, in isolation, is not a derivative work of the Library, and 783 | therefore falls outside the scope of this License. 784 | 785 | However, linking a "work that uses the Library" with the Library 786 | creates an executable that is a derivative of the Library (because it 787 | contains portions of the Library), rather than a "work that uses the 788 | library". The executable is therefore covered by this License. 789 | Section 6 states terms for distribution of such executables. 790 | 791 | When a "work that uses the Library" uses material from a header file 792 | that is part of the Library, the object code for the work may be a 793 | derivative work of the Library even though the source code is not. 794 | Whether this is true is especially significant if the work can be 795 | linked without the Library, or if the work is itself a library. The 796 | threshold for this to be true is not precisely defined by law. 797 | 798 | If such an object file uses only numerical parameters, data 799 | structure layouts and accessors, and small macros and small inline 800 | functions (ten lines or less in length), then the use of the object 801 | file is unrestricted, regardless of whether it is legally a derivative 802 | work. (Executables containing this object code plus portions of the 803 | Library will still fall under Section 6.) 804 | 805 | Otherwise, if the work is a derivative of the Library, you may 806 | distribute the object code for the work under the terms of Section 6. 807 | Any executables containing that work also fall under Section 6, 808 | whether or not they are linked directly with the Library itself. 809 | 810 | 6. As an exception to the Sections above, you may also combine or 811 | link a "work that uses the Library" with the Library to produce a 812 | work containing portions of the Library, and distribute that work 813 | under terms of your choice, provided that the terms permit 814 | modification of the work for the customer's own use and reverse 815 | engineering for debugging such modifications. 816 | 817 | You must give prominent notice with each copy of the work that the 818 | Library is used in it and that the Library and its use are covered by 819 | this License. You must supply a copy of this License. If the work 820 | during execution displays copyright notices, you must include the 821 | copyright notice for the Library among them, as well as a reference 822 | directing the user to the copy of this License. Also, you must do one 823 | of these things: 824 | 825 | a) Accompany the work with the complete corresponding 826 | machine-readable source code for the Library including whatever 827 | changes were used in the work (which must be distributed under 828 | Sections 1 and 2 above); and, if the work is an executable linked 829 | with the Library, with the complete machine-readable "work that 830 | uses the Library", as object code and/or source code, so that the 831 | user can modify the Library and then relink to produce a modified 832 | executable containing the modified Library. (It is understood 833 | that the user who changes the contents of definitions files in the 834 | Library will not necessarily be able to recompile the application 835 | to use the modified definitions.) 836 | 837 | b) Use a suitable shared library mechanism for linking with the 838 | Library. A suitable mechanism is one that (1) uses at run time a 839 | copy of the library already present on the user's computer system, 840 | rather than copying library functions into the executable, and (2) 841 | will operate properly with a modified version of the library, if 842 | the user installs one, as long as the modified version is 843 | interface-compatible with the version that the work was made with. 844 | 845 | c) Accompany the work with a written offer, valid for at 846 | least three years, to give the same user the materials 847 | specified in Subsection 6a, above, for a charge no more 848 | than the cost of performing this distribution. 849 | 850 | d) If distribution of the work is made by offering access to copy 851 | from a designated place, offer equivalent access to copy the above 852 | specified materials from the same place. 853 | 854 | e) Verify that the user has already received a copy of these 855 | materials or that you have already sent this user a copy. 856 | 857 | For an executable, the required form of the "work that uses the 858 | Library" must include any data and utility programs needed for 859 | reproducing the executable from it. However, as a special exception, 860 | the materials to be distributed need not include anything that is 861 | normally distributed (in either source or binary form) with the major 862 | components (compiler, kernel, and so on) of the operating system on 863 | which the executable runs, unless that component itself accompanies 864 | the executable. 865 | 866 | It may happen that this requirement contradicts the license 867 | restrictions of other proprietary libraries that do not normally 868 | accompany the operating system. Such a contradiction means you cannot 869 | use both them and the Library together in an executable that you 870 | distribute. 871 | 872 | 7. You may place library facilities that are a work based on the 873 | Library side-by-side in a single library together with other library 874 | facilities not covered by this License, and distribute such a combined 875 | library, provided that the separate distribution of the work based on 876 | the Library and of the other library facilities is otherwise 877 | permitted, and provided that you do these two things: 878 | 879 | a) Accompany the combined library with a copy of the same work 880 | based on the Library, uncombined with any other library 881 | facilities. This must be distributed under the terms of the 882 | Sections above. 883 | 884 | b) Give prominent notice with the combined library of the fact 885 | that part of it is a work based on the Library, and explaining 886 | where to find the accompanying uncombined form of the same work. 887 | 888 | 8. You may not copy, modify, sublicense, link with, or distribute 889 | the Library except as expressly provided under this License. Any 890 | attempt otherwise to copy, modify, sublicense, link with, or 891 | distribute the Library is void, and will automatically terminate your 892 | rights under this License. However, parties who have received copies, 893 | or rights, from you under this License will not have their licenses 894 | terminated so long as such parties remain in full compliance. 895 | 896 | 9. You are not required to accept this License, since you have not 897 | signed it. However, nothing else grants you permission to modify or 898 | distribute the Library or its derivative works. These actions are 899 | prohibited by law if you do not accept this License. Therefore, by 900 | modifying or distributing the Library (or any work based on the 901 | Library), you indicate your acceptance of this License to do so, and 902 | all its terms and conditions for copying, distributing or modifying 903 | the Library or works based on it. 904 | 905 | 10. Each time you redistribute the Library (or any work based on the 906 | Library), the recipient automatically receives a license from the 907 | original licensor to copy, distribute, link with or modify the Library 908 | subject to these terms and conditions. You may not impose any further 909 | restrictions on the recipients' exercise of the rights granted herein. 910 | You are not responsible for enforcing compliance by third parties with 911 | this License. 912 | 913 | 11. If, as a consequence of a court judgment or allegation of patent 914 | infringement or for any other reason (not limited to patent issues), 915 | conditions are imposed on you (whether by court order, agreement or 916 | otherwise) that contradict the conditions of this License, they do not 917 | excuse you from the conditions of this License. If you cannot 918 | distribute so as to satisfy simultaneously your obligations under this 919 | License and any other pertinent obligations, then as a consequence you 920 | may not distribute the Library at all. For example, if a patent 921 | license would not permit royalty-free redistribution of the Library by 922 | all those who receive copies directly or indirectly through you, then 923 | the only way you could satisfy both it and this License would be to 924 | refrain entirely from distribution of the Library. 925 | 926 | If any portion of this section is held invalid or unenforceable under any 927 | particular circumstance, the balance of the section is intended to apply, 928 | and the section as a whole is intended to apply in other circumstances. 929 | 930 | It is not the purpose of this section to induce you to infringe any 931 | patents or other property right claims or to contest validity of any 932 | such claims; this section has the sole purpose of protecting the 933 | integrity of the free software distribution system which is 934 | implemented by public license practices. Many people have made 935 | generous contributions to the wide range of software distributed 936 | through that system in reliance on consistent application of that 937 | system; it is up to the author/donor to decide if he or she is willing 938 | to distribute software through any other system and a licensee cannot 939 | impose that choice. 940 | 941 | This section is intended to make thoroughly clear what is believed to 942 | be a consequence of the rest of this License. 943 | 944 | 12. If the distribution and/or use of the Library is restricted in 945 | certain countries either by patents or by copyrighted interfaces, the 946 | original copyright holder who places the Library under this License may add 947 | an explicit geographical distribution limitation excluding those countries, 948 | so that distribution is permitted only in or among countries not thus 949 | excluded. In such case, this License incorporates the limitation as if 950 | written in the body of this License. 951 | 952 | 13. The Free Software Foundation may publish revised and/or new 953 | versions of the Lesser General Public License from time to time. 954 | Such new versions will be similar in spirit to the present version, 955 | but may differ in detail to address new problems or concerns. 956 | 957 | Each version is given a distinguishing version number. If the Library 958 | specifies a version number of this License which applies to it and 959 | "any later version", you have the option of following the terms and 960 | conditions either of that version or of any later version published by 961 | the Free Software Foundation. If the Library does not specify a 962 | license version number, you may choose any version ever published by 963 | the Free Software Foundation. 964 | 965 | 14. If you wish to incorporate parts of the Library into other free 966 | programs whose distribution conditions are incompatible with these, 967 | write to the author to ask for permission. For software which is 968 | copyrighted by the Free Software Foundation, write to the Free 969 | Software Foundation; we sometimes make exceptions for this. Our 970 | decision will be guided by the two goals of preserving the free status 971 | of all derivatives of our free software and of promoting the sharing 972 | and reuse of software generally. 973 | 974 | NO WARRANTY 975 | 976 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 977 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 978 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 979 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 980 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 981 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 982 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 983 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 984 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 985 | 986 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 987 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 988 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 989 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 990 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 991 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 992 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 993 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 994 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 995 | DAMAGES. 996 | 997 | END OF TERMS AND CONDITIONS 998 | 999 | How to Apply These Terms to Your New Libraries 1000 | 1001 | If you develop a new library, and you want it to be of the greatest 1002 | possible use to the public, we recommend making it free software that 1003 | everyone can redistribute and change. You can do so by permitting 1004 | redistribution under these terms (or, alternatively, under the terms of the 1005 | ordinary General Public License). 1006 | 1007 | To apply these terms, attach the following notices to the library. It is 1008 | safest to attach them to the start of each source file to most effectively 1009 | convey the exclusion of warranty; and each file should have at least the 1010 | "copyright" line and a pointer to where the full notice is found. 1011 | 1012 | 1013 | Copyright (C) 1014 | 1015 | This library is free software; you can redistribute it and/or 1016 | modify it under the terms of the GNU Lesser General Public 1017 | License as published by the Free Software Foundation; either 1018 | version 2.1 of the License, or (at your option) any later version. 1019 | 1020 | This library is distributed in the hope that it will be useful, 1021 | but WITHOUT ANY WARRANTY; without even the implied warranty of 1022 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1023 | Lesser General Public License for more details. 1024 | 1025 | You should have received a copy of the GNU Lesser General Public 1026 | License along with this library; if not, write to the Free Software 1027 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 1028 | 1029 | Also add information on how to contact you by electronic and paper mail. 1030 | 1031 | You should also get your employer (if you work as a programmer) or your 1032 | school, if any, to sign a "copyright disclaimer" for the library, if 1033 | necessary. Here is a sample; alter the names: 1034 | 1035 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 1036 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 1037 | 1038 | , 1 April 1990 1039 | Ty Coon, President of Vice 1040 | 1041 | That's all there is to it! 1042 | 1043 | The following licenses cover code other than JRuby which is included with JRuby. 1044 | 1045 | Licenses listed below include: 1046 | 1047 | * GNU General Public License version 3 1048 | * Apache 2.0 License 1049 | * BSD License 1050 | * Apache Software License Version 1.1 1051 | * MIT License 1052 | 1053 | The complete text of the GNU General Public License version 3 is as follows: 1054 | 1055 | GNU GENERAL PUBLIC LICENSE 1056 | Version 3, 29 June 2007 1057 | 1058 | Copyright (C) 2007 Free Software Foundation, Inc. 1059 | Everyone is permitted to copy and distribute verbatim copies 1060 | of this license document, but changing it is not allowed. 1061 | 1062 | Preamble 1063 | 1064 | The GNU General Public License is a free, copyleft license for 1065 | software and other kinds of works. 1066 | 1067 | The licenses for most software and other practical works are designed 1068 | to take away your freedom to share and change the works. By contrast, 1069 | the GNU General Public License is intended to guarantee your freedom to 1070 | share and change all versions of a program--to make sure it remains free 1071 | software for all its users. We, the Free Software Foundation, use the 1072 | GNU General Public License for most of our software; it applies also to 1073 | any other work released this way by its authors. You can apply it to 1074 | your programs, too. 1075 | 1076 | When we speak of free software, we are referring to freedom, not 1077 | price. Our General Public Licenses are designed to make sure that you 1078 | have the freedom to distribute copies of free software (and charge for 1079 | them if you wish), that you receive source code or can get it if you 1080 | want it, that you can change the software or use pieces of it in new 1081 | free programs, and that you know you can do these things. 1082 | 1083 | To protect your rights, we need to prevent others from denying you 1084 | these rights or asking you to surrender the rights. Therefore, you have 1085 | certain responsibilities if you distribute copies of the software, or if 1086 | you modify it: responsibilities to respect the freedom of others. 1087 | 1088 | For example, if you distribute copies of such a program, whether 1089 | gratis or for a fee, you must pass on to the recipients the same 1090 | freedoms that you received. You must make sure that they, too, receive 1091 | or can get the source code. And you must show them these terms so they 1092 | know their rights. 1093 | 1094 | Developers that use the GNU GPL protect your rights with two steps: 1095 | (1) assert copyright on the software, and (2) offer you this License 1096 | giving you legal permission to copy, distribute and/or modify it. 1097 | 1098 | For the developers' and authors' protection, the GPL clearly explains 1099 | that there is no warranty for this free software. For both users' and 1100 | authors' sake, the GPL requires that modified versions be marked as 1101 | changed, so that their problems will not be attributed erroneously to 1102 | authors of previous versions. 1103 | 1104 | Some devices are designed to deny users access to install or run 1105 | modified versions of the software inside them, although the manufacturer 1106 | can do so. This is fundamentally incompatible with the aim of 1107 | protecting users' freedom to change the software. The systematic 1108 | pattern of such abuse occurs in the area of products for individuals to 1109 | use, which is precisely where it is most unacceptable. Therefore, we 1110 | have designed this version of the GPL to prohibit the practice for those 1111 | products. If such problems arise substantially in other domains, we 1112 | stand ready to extend this provision to those domains in future versions 1113 | of the GPL, as needed to protect the freedom of users. 1114 | 1115 | Finally, every program is threatened constantly by software patents. 1116 | States should not allow patents to restrict development and use of 1117 | software on general-purpose computers, but in those that do, we wish to 1118 | avoid the special danger that patents applied to a free program could 1119 | make it effectively proprietary. To prevent this, the GPL assures that 1120 | patents cannot be used to render the program non-free. 1121 | 1122 | The precise terms and conditions for copying, distribution and 1123 | modification follow. 1124 | 1125 | TERMS AND CONDITIONS 1126 | 1127 | 0. Definitions. 1128 | 1129 | "This License" refers to version 3 of the GNU General Public License. 1130 | 1131 | "Copyright" also means copyright-like laws that apply to other kinds of 1132 | works, such as semiconductor masks. 1133 | 1134 | "The Program" refers to any copyrightable work licensed under this 1135 | License. Each licensee is addressed as "you". "Licensees" and 1136 | "recipients" may be individuals or organizations. 1137 | 1138 | To "modify" a work means to copy from or adapt all or part of the work 1139 | in a fashion requiring copyright permission, other than the making of an 1140 | exact copy. The resulting work is called a "modified version" of the 1141 | earlier work or a work "based on" the earlier work. 1142 | 1143 | A "covered work" means either the unmodified Program or a work based 1144 | on the Program. 1145 | 1146 | To "propagate" a work means to do anything with it that, without 1147 | permission, would make you directly or secondarily liable for 1148 | infringement under applicable copyright law, except executing it on a 1149 | computer or modifying a private copy. Propagation includes copying, 1150 | distribution (with or without modification), making available to the 1151 | public, and in some countries other activities as well. 1152 | 1153 | To "convey" a work means any kind of propagation that enables other 1154 | parties to make or receive copies. Mere interaction with a user through 1155 | a computer network, with no transfer of a copy, is not conveying. 1156 | 1157 | An interactive user interface displays "Appropriate Legal Notices" 1158 | to the extent that it includes a convenient and prominently visible 1159 | feature that (1) displays an appropriate copyright notice, and (2) 1160 | tells the user that there is no warranty for the work (except to the 1161 | extent that warranties are provided), that licensees may convey the 1162 | work under this License, and how to view a copy of this License. If 1163 | the interface presents a list of user commands or options, such as a 1164 | menu, a prominent item in the list meets this criterion. 1165 | 1166 | 1. Source Code. 1167 | 1168 | The "source code" for a work means the preferred form of the work 1169 | for making modifications to it. "Object code" means any non-source 1170 | form of a work. 1171 | 1172 | A "Standard Interface" means an interface that either is an official 1173 | standard defined by a recognized standards body, or, in the case of 1174 | interfaces specified for a particular programming language, one that 1175 | is widely used among developers working in that language. 1176 | 1177 | The "System Libraries" of an executable work include anything, other 1178 | than the work as a whole, that (a) is included in the normal form of 1179 | packaging a Major Component, but which is not part of that Major 1180 | Component, and (b) serves only to enable use of the work with that 1181 | Major Component, or to implement a Standard Interface for which an 1182 | implementation is available to the public in source code form. A 1183 | "Major Component", in this context, means a major essential component 1184 | (kernel, window system, and so on) of the specific operating system 1185 | (if any) on which the executable work runs, or a compiler used to 1186 | produce the work, or an object code interpreter used to run it. 1187 | 1188 | The "Corresponding Source" for a work in object code form means all 1189 | the source code needed to generate, install, and (for an executable 1190 | work) run the object code and to modify the work, including scripts to 1191 | control those activities. However, it does not include the work's 1192 | System Libraries, or general-purpose tools or generally available free 1193 | programs which are used unmodified in performing those activities but 1194 | which are not part of the work. For example, Corresponding Source 1195 | includes interface definition files associated with source files for 1196 | the work, and the source code for shared libraries and dynamically 1197 | linked subprograms that the work is specifically designed to require, 1198 | such as by intimate data communication or control flow between those 1199 | subprograms and other parts of the work. 1200 | 1201 | The Corresponding Source need not include anything that users 1202 | can regenerate automatically from other parts of the Corresponding 1203 | Source. 1204 | 1205 | The Corresponding Source for a work in source code form is that 1206 | same work. 1207 | 1208 | 2. Basic Permissions. 1209 | 1210 | All rights granted under this License are granted for the term of 1211 | copyright on the Program, and are irrevocable provided the stated 1212 | conditions are met. This License explicitly affirms your unlimited 1213 | permission to run the unmodified Program. The output from running a 1214 | covered work is covered by this License only if the output, given its 1215 | content, constitutes a covered work. This License acknowledges your 1216 | rights of fair use or other equivalent, as provided by copyright law. 1217 | 1218 | You may make, run and propagate covered works that you do not 1219 | convey, without conditions so long as your license otherwise remains 1220 | in force. You may convey covered works to others for the sole purpose 1221 | of having them make modifications exclusively for you, or provide you 1222 | with facilities for running those works, provided that you comply with 1223 | the terms of this License in conveying all material for which you do 1224 | not control copyright. Those thus making or running the covered works 1225 | for you must do so exclusively on your behalf, under your direction 1226 | and control, on terms that prohibit them from making any copies of 1227 | your copyrighted material outside their relationship with you. 1228 | 1229 | Conveying under any other circumstances is permitted solely under 1230 | the conditions stated below. Sublicensing is not allowed; section 10 1231 | makes it unnecessary. 1232 | 1233 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 1234 | 1235 | No covered work shall be deemed part of an effective technological 1236 | measure under any applicable law fulfilling obligations under article 1237 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 1238 | similar laws prohibiting or restricting circumvention of such 1239 | measures. 1240 | 1241 | When you convey a covered work, you waive any legal power to forbid 1242 | circumvention of technological measures to the extent such circumvention 1243 | is effected by exercising rights under this License with respect to 1244 | the covered work, and you disclaim any intention to limit operation or 1245 | modification of the work as a means of enforcing, against the work's 1246 | users, your or third parties' legal rights to forbid circumvention of 1247 | technological measures. 1248 | 1249 | 4. Conveying Verbatim Copies. 1250 | 1251 | You may convey verbatim copies of the Program's source code as you 1252 | receive it, in any medium, provided that you conspicuously and 1253 | appropriately publish on each copy an appropriate copyright notice; 1254 | keep intact all notices stating that this License and any 1255 | non-permissive terms added in accord with section 7 apply to the code; 1256 | keep intact all notices of the absence of any warranty; and give all 1257 | recipients a copy of this License along with the Program. 1258 | 1259 | You may charge any price or no price for each copy that you convey, 1260 | and you may offer support or warranty protection for a fee. 1261 | 1262 | 5. Conveying Modified Source Versions. 1263 | 1264 | You may convey a work based on the Program, or the modifications to 1265 | produce it from the Program, in the form of source code under the 1266 | terms of section 4, provided that you also meet all of these conditions: 1267 | 1268 | a) The work must carry prominent notices stating that you modified 1269 | it, and giving a relevant date. 1270 | 1271 | b) The work must carry prominent notices stating that it is 1272 | released under this License and any conditions added under section 1273 | 7. This requirement modifies the requirement in section 4 to 1274 | "keep intact all notices". 1275 | 1276 | c) You must license the entire work, as a whole, under this 1277 | License to anyone who comes into possession of a copy. This 1278 | License will therefore apply, along with any applicable section 7 1279 | additional terms, to the whole of the work, and all its parts, 1280 | regardless of how they are packaged. This License gives no 1281 | permission to license the work in any other way, but it does not 1282 | invalidate such permission if you have separately received it. 1283 | 1284 | d) If the work has interactive user interfaces, each must display 1285 | Appropriate Legal Notices; however, if the Program has interactive 1286 | interfaces that do not display Appropriate Legal Notices, your 1287 | work need not make them do so. 1288 | 1289 | A compilation of a covered work with other separate and independent 1290 | works, which are not by their nature extensions of the covered work, 1291 | and which are not combined with it such as to form a larger program, 1292 | in or on a volume of a storage or distribution medium, is called an 1293 | "aggregate" if the compilation and its resulting copyright are not 1294 | used to limit the access or legal rights of the compilation's users 1295 | beyond what the individual works permit. Inclusion of a covered work 1296 | in an aggregate does not cause this License to apply to the other 1297 | parts of the aggregate. 1298 | 1299 | 6. Conveying Non-Source Forms. 1300 | 1301 | You may convey a covered work in object code form under the terms 1302 | of sections 4 and 5, provided that you also convey the 1303 | machine-readable Corresponding Source under the terms of this License, 1304 | in one of these ways: 1305 | 1306 | a) Convey the object code in, or embodied in, a physical product 1307 | (including a physical distribution medium), accompanied by the 1308 | Corresponding Source fixed on a durable physical medium 1309 | customarily used for software interchange. 1310 | 1311 | b) Convey the object code in, or embodied in, a physical product 1312 | (including a physical distribution medium), accompanied by a 1313 | written offer, valid for at least three years and valid for as 1314 | long as you offer spare parts or customer support for that product 1315 | model, to give anyone who possesses the object code either (1) a 1316 | copy of the Corresponding Source for all the software in the 1317 | product that is covered by this License, on a durable physical 1318 | medium customarily used for software interchange, for a price no 1319 | more than your reasonable cost of physically performing this 1320 | conveying of source, or (2) access to copy the 1321 | Corresponding Source from a network server at no charge. 1322 | 1323 | c) Convey individual copies of the object code with a copy of the 1324 | written offer to provide the Corresponding Source. This 1325 | alternative is allowed only occasionally and noncommercially, and 1326 | only if you received the object code with such an offer, in accord 1327 | with subsection 6b. 1328 | 1329 | d) Convey the object code by offering access from a designated 1330 | place (gratis or for a charge), and offer equivalent access to the 1331 | Corresponding Source in the same way through the same place at no 1332 | further charge. You need not require recipients to copy the 1333 | Corresponding Source along with the object code. If the place to 1334 | copy the object code is a network server, the Corresponding Source 1335 | may be on a different server (operated by you or a third party) 1336 | that supports equivalent copying facilities, provided you maintain 1337 | clear directions next to the object code saying where to find the 1338 | Corresponding Source. Regardless of what server hosts the 1339 | Corresponding Source, you remain obligated to ensure that it is 1340 | available for as long as needed to satisfy these requirements. 1341 | 1342 | e) Convey the object code using peer-to-peer transmission, provided 1343 | you inform other peers where the object code and Corresponding 1344 | Source of the work are being offered to the general public at no 1345 | charge under subsection 6d. 1346 | 1347 | A separable portion of the object code, whose source code is excluded 1348 | from the Corresponding Source as a System Library, need not be 1349 | included in conveying the object code work. 1350 | 1351 | A "User Product" is either (1) a "consumer product", which means any 1352 | tangible personal property which is normally used for personal, family, 1353 | or household purposes, or (2) anything designed or sold for incorporation 1354 | into a dwelling. In determining whether a product is a consumer product, 1355 | doubtful cases shall be resolved in favor of coverage. For a particular 1356 | product received by a particular user, "normally used" refers to a 1357 | typical or common use of that class of product, regardless of the status 1358 | of the particular user or of the way in which the particular user 1359 | actually uses, or expects or is expected to use, the product. A product 1360 | is a consumer product regardless of whether the product has substantial 1361 | commercial, industrial or non-consumer uses, unless such uses represent 1362 | the only significant mode of use of the product. 1363 | 1364 | "Installation Information" for a User Product means any methods, 1365 | procedures, authorization keys, or other information required to install 1366 | and execute modified versions of a covered work in that User Product from 1367 | a modified version of its Corresponding Source. The information must 1368 | suffice to ensure that the continued functioning of the modified object 1369 | code is in no case prevented or interfered with solely because 1370 | modification has been made. 1371 | 1372 | If you convey an object code work under this section in, or with, or 1373 | specifically for use in, a User Product, and the conveying occurs as 1374 | part of a transaction in which the right of possession and use of the 1375 | User Product is transferred to the recipient in perpetuity or for a 1376 | fixed term (regardless of how the transaction is characterized), the 1377 | Corresponding Source conveyed under this section must be accompanied 1378 | by the Installation Information. But this requirement does not apply 1379 | if neither you nor any third party retains the ability to install 1380 | modified object code on the User Product (for example, the work has 1381 | been installed in ROM). 1382 | 1383 | The requirement to provide Installation Information does not include a 1384 | requirement to continue to provide support service, warranty, or updates 1385 | for a work that has been modified or installed by the recipient, or for 1386 | the User Product in which it has been modified or installed. Access to a 1387 | network may be denied when the modification itself materially and 1388 | adversely affects the operation of the network or violates the rules and 1389 | protocols for communication across the network. 1390 | 1391 | Corresponding Source conveyed, and Installation Information provided, 1392 | in accord with this section must be in a format that is publicly 1393 | documented (and with an implementation available to the public in 1394 | source code form), and must require no special password or key for 1395 | unpacking, reading or copying. 1396 | 1397 | 7. Additional Terms. 1398 | 1399 | "Additional permissions" are terms that supplement the terms of this 1400 | License by making exceptions from one or more of its conditions. 1401 | Additional permissions that are applicable to the entire Program shall 1402 | be treated as though they were included in this License, to the extent 1403 | that they are valid under applicable law. If additional permissions 1404 | apply only to part of the Program, that part may be used separately 1405 | under those permissions, but the entire Program remains governed by 1406 | this License without regard to the additional permissions. 1407 | 1408 | When you convey a copy of a covered work, you may at your option 1409 | remove any additional permissions from that copy, or from any part of 1410 | it. (Additional permissions may be written to require their own 1411 | removal in certain cases when you modify the work.) You may place 1412 | additional permissions on material, added by you to a covered work, 1413 | for which you have or can give appropriate copyright permission. 1414 | 1415 | Notwithstanding any other provision of this License, for material you 1416 | add to a covered work, you may (if authorized by the copyright holders of 1417 | that material) supplement the terms of this License with terms: 1418 | 1419 | a) Disclaiming warranty or limiting liability differently from the 1420 | terms of sections 15 and 16 of this License; or 1421 | 1422 | b) Requiring preservation of specified reasonable legal notices or 1423 | author attributions in that material or in the Appropriate Legal 1424 | Notices displayed by works containing it; or 1425 | 1426 | c) Prohibiting misrepresentation of the origin of that material, or 1427 | requiring that modified versions of such material be marked in 1428 | reasonable ways as different from the original version; or 1429 | 1430 | d) Limiting the use for publicity purposes of names of licensors or 1431 | authors of the material; or 1432 | 1433 | e) Declining to grant rights under trademark law for use of some 1434 | trade names, trademarks, or service marks; or 1435 | 1436 | f) Requiring indemnification of licensors and authors of that 1437 | material by anyone who conveys the material (or modified versions of 1438 | it) with contractual assumptions of liability to the recipient, for 1439 | any liability that these contractual assumptions directly impose on 1440 | those licensors and authors. 1441 | 1442 | All other non-permissive additional terms are considered "further 1443 | restrictions" within the meaning of section 10. If the Program as you 1444 | received it, or any part of it, contains a notice stating that it is 1445 | governed by this License along with a term that is a further 1446 | restriction, you may remove that term. If a license document contains 1447 | a further restriction but permits relicensing or conveying under this 1448 | License, you may add to a covered work material governed by the terms 1449 | of that license document, provided that the further restriction does 1450 | not survive such relicensing or conveying. 1451 | 1452 | If you add terms to a covered work in accord with this section, you 1453 | must place, in the relevant source files, a statement of the 1454 | additional terms that apply to those files, or a notice indicating 1455 | where to find the applicable terms. 1456 | 1457 | Additional terms, permissive or non-permissive, may be stated in the 1458 | form of a separately written license, or stated as exceptions; 1459 | the above requirements apply either way. 1460 | 1461 | 8. Termination. 1462 | 1463 | You may not propagate or modify a covered work except as expressly 1464 | provided under this License. Any attempt otherwise to propagate or 1465 | modify it is void, and will automatically terminate your rights under 1466 | this License (including any patent licenses granted under the third 1467 | paragraph of section 11). 1468 | 1469 | However, if you cease all violation of this License, then your 1470 | license from a particular copyright holder is reinstated (a) 1471 | provisionally, unless and until the copyright holder explicitly and 1472 | finally terminates your license, and (b) permanently, if the copyright 1473 | holder fails to notify you of the violation by some reasonable means 1474 | prior to 60 days after the cessation. 1475 | 1476 | Moreover, your license from a particular copyright holder is 1477 | reinstated permanently if the copyright holder notifies you of the 1478 | violation by some reasonable means, this is the first time you have 1479 | received notice of violation of this License (for any work) from that 1480 | copyright holder, and you cure the violation prior to 30 days after 1481 | your receipt of the notice. 1482 | 1483 | Termination of your rights under this section does not terminate the 1484 | licenses of parties who have received copies or rights from you under 1485 | this License. If your rights have been terminated and not permanently 1486 | reinstated, you do not qualify to receive new licenses for the same 1487 | material under section 10. 1488 | 1489 | 9. Acceptance Not Required for Having Copies. 1490 | 1491 | You are not required to accept this License in order to receive or 1492 | run a copy of the Program. Ancillary propagation of a covered work 1493 | occurring solely as a consequence of using peer-to-peer transmission 1494 | to receive a copy likewise does not require acceptance. However, 1495 | nothing other than this License grants you permission to propagate or 1496 | modify any covered work. These actions infringe copyright if you do 1497 | not accept this License. Therefore, by modifying or propagating a 1498 | covered work, you indicate your acceptance of this License to do so. 1499 | 1500 | 10. Automatic Licensing of Downstream Recipients. 1501 | 1502 | Each time you convey a covered work, the recipient automatically 1503 | receives a license from the original licensors, to run, modify and 1504 | propagate that work, subject to this License. You are not responsible 1505 | for enforcing compliance by third parties with this License. 1506 | 1507 | An "entity transaction" is a transaction transferring control of an 1508 | organization, or substantially all assets of one, or subdividing an 1509 | organization, or merging organizations. If propagation of a covered 1510 | work results from an entity transaction, each party to that 1511 | transaction who receives a copy of the work also receives whatever 1512 | licenses to the work the party's predecessor in interest had or could 1513 | give under the previous paragraph, plus a right to possession of the 1514 | Corresponding Source of the work from the predecessor in interest, if 1515 | the predecessor has it or can get it with reasonable efforts. 1516 | 1517 | You may not impose any further restrictions on the exercise of the 1518 | rights granted or affirmed under this License. For example, you may 1519 | not impose a license fee, royalty, or other charge for exercise of 1520 | rights granted under this License, and you may not initiate litigation 1521 | (including a cross-claim or counterclaim in a lawsuit) alleging that 1522 | any patent claim is infringed by making, using, selling, offering for 1523 | sale, or importing the Program or any portion of it. 1524 | 1525 | 11. Patents. 1526 | 1527 | A "contributor" is a copyright holder who authorizes use under this 1528 | License of the Program or a work on which the Program is based. The 1529 | work thus licensed is called the contributor's "contributor version". 1530 | 1531 | A contributor's "essential patent claims" are all patent claims 1532 | owned or controlled by the contributor, whether already acquired or 1533 | hereafter acquired, that would be infringed by some manner, permitted 1534 | by this License, of making, using, or selling its contributor version, 1535 | but do not include claims that would be infringed only as a 1536 | consequence of further modification of the contributor version. For 1537 | purposes of this definition, "control" includes the right to grant 1538 | patent sublicenses in a manner consistent with the requirements of 1539 | this License. 1540 | 1541 | Each contributor grants you a non-exclusive, worldwide, royalty-free 1542 | patent license under the contributor's essential patent claims, to 1543 | make, use, sell, offer for sale, import and otherwise run, modify and 1544 | propagate the contents of its contributor version. 1545 | 1546 | In the following three paragraphs, a "patent license" is any express 1547 | agreement or commitment, however denominated, not to enforce a patent 1548 | (such as an express permission to practice a patent or covenant not to 1549 | sue for patent infringement). To "grant" such a patent license to a 1550 | party means to make such an agreement or commitment not to enforce a 1551 | patent against the party. 1552 | 1553 | If you convey a covered work, knowingly relying on a patent license, 1554 | and the Corresponding Source of the work is not available for anyone 1555 | to copy, free of charge and under the terms of this License, through a 1556 | publicly available network server or other readily accessible means, 1557 | then you must either (1) cause the Corresponding Source to be so 1558 | available, or (2) arrange to deprive yourself of the benefit of the 1559 | patent license for this particular work, or (3) arrange, in a manner 1560 | consistent with the requirements of this License, to extend the patent 1561 | license to downstream recipients. "Knowingly relying" means you have 1562 | actual knowledge that, but for the patent license, your conveying the 1563 | covered work in a country, or your recipient's use of the covered work 1564 | in a country, would infringe one or more identifiable patents in that 1565 | country that you have reason to believe are valid. 1566 | 1567 | If, pursuant to or in connection with a single transaction or 1568 | arrangement, you convey, or propagate by procuring conveyance of, a 1569 | covered work, and grant a patent license to some of the parties 1570 | receiving the covered work authorizing them to use, propagate, modify 1571 | or convey a specific copy of the covered work, then the patent license 1572 | you grant is automatically extended to all recipients of the covered 1573 | work and works based on it. 1574 | 1575 | A patent license is "discriminatory" if it does not include within 1576 | the scope of its coverage, prohibits the exercise of, or is 1577 | conditioned on the non-exercise of one or more of the rights that are 1578 | specifically granted under this License. You may not convey a covered 1579 | work if you are a party to an arrangement with a third party that is 1580 | in the business of distributing software, under which you make payment 1581 | to the third party based on the extent of your activity of conveying 1582 | the work, and under which the third party grants, to any of the 1583 | parties who would receive the covered work from you, a discriminatory 1584 | patent license (a) in connection with copies of the covered work 1585 | conveyed by you (or copies made from those copies), or (b) primarily 1586 | for and in connection with specific products or compilations that 1587 | contain the covered work, unless you entered into that arrangement, 1588 | or that patent license was granted, prior to 28 March 2007. 1589 | 1590 | Nothing in this License shall be construed as excluding or limiting 1591 | any implied license or other defenses to infringement that may 1592 | otherwise be available to you under applicable patent law. 1593 | 1594 | 12. No Surrender of Others' Freedom. 1595 | 1596 | If conditions are imposed on you (whether by court order, agreement or 1597 | otherwise) that contradict the conditions of this License, they do not 1598 | excuse you from the conditions of this License. If you cannot convey a 1599 | covered work so as to satisfy simultaneously your obligations under this 1600 | License and any other pertinent obligations, then as a consequence you may 1601 | not convey it at all. For example, if you agree to terms that obligate you 1602 | to collect a royalty for further conveying from those to whom you convey 1603 | the Program, the only way you could satisfy both those terms and this 1604 | License would be to refrain entirely from conveying the Program. 1605 | 1606 | 13. Use with the GNU Affero General Public License. 1607 | 1608 | Notwithstanding any other provision of this License, you have 1609 | permission to link or combine any covered work with a work licensed 1610 | under version 3 of the GNU Affero General Public License into a single 1611 | combined work, and to convey the resulting work. The terms of this 1612 | License will continue to apply to the part which is the covered work, 1613 | but the special requirements of the GNU Affero General Public License, 1614 | section 13, concerning interaction through a network will apply to the 1615 | combination as such. 1616 | 1617 | 14. Revised Versions of this License. 1618 | 1619 | The Free Software Foundation may publish revised and/or new versions of 1620 | the GNU General Public License from time to time. Such new versions will 1621 | be similar in spirit to the present version, but may differ in detail to 1622 | address new problems or concerns. 1623 | 1624 | Each version is given a distinguishing version number. If the 1625 | Program specifies that a certain numbered version of the GNU General 1626 | Public License "or any later version" applies to it, you have the 1627 | option of following the terms and conditions either of that numbered 1628 | version or of any later version published by the Free Software 1629 | Foundation. If the Program does not specify a version number of the 1630 | GNU General Public License, you may choose any version ever published 1631 | by the Free Software Foundation. 1632 | 1633 | If the Program specifies that a proxy can decide which future 1634 | versions of the GNU General Public License can be used, that proxy's 1635 | public statement of acceptance of a version permanently authorizes you 1636 | to choose that version for the Program. 1637 | 1638 | Later license versions may give you additional or different 1639 | permissions. However, no additional obligations are imposed on any 1640 | author or copyright holder as a result of your choosing to follow a 1641 | later version. 1642 | 1643 | 15. Disclaimer of Warranty. 1644 | 1645 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 1646 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 1647 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 1648 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 1649 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1650 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 1651 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 1652 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 1653 | 1654 | 16. Limitation of Liability. 1655 | 1656 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 1657 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 1658 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 1659 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 1660 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 1661 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 1662 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 1663 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 1664 | SUCH DAMAGES. 1665 | 1666 | 17. Interpretation of Sections 15 and 16. 1667 | 1668 | If the disclaimer of warranty and limitation of liability provided 1669 | above cannot be given local legal effect according to their terms, 1670 | reviewing courts shall apply local law that most closely approximates 1671 | an absolute waiver of all civil liability in connection with the 1672 | Program, unless a warranty or assumption of liability accompanies a 1673 | copy of the Program in return for a fee. 1674 | 1675 | END OF TERMS AND CONDITIONS 1676 | 1677 | How to Apply These Terms to Your New Programs 1678 | 1679 | If you develop a new program, and you want it to be of the greatest 1680 | possible use to the public, the best way to achieve this is to make it 1681 | free software which everyone can redistribute and change under these terms. 1682 | 1683 | To do so, attach the following notices to the program. It is safest 1684 | to attach them to the start of each source file to most effectively 1685 | state the exclusion of warranty; and each file should have at least 1686 | the "copyright" line and a pointer to where the full notice is found. 1687 | 1688 | 1689 | Copyright (C) 1690 | 1691 | This program is free software: you can redistribute it and/or modify 1692 | it under the terms of the GNU General Public License as published by 1693 | the Free Software Foundation, either version 3 of the License, or 1694 | (at your option) any later version. 1695 | 1696 | This program is distributed in the hope that it will be useful, 1697 | but WITHOUT ANY WARRANTY; without even the implied warranty of 1698 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1699 | GNU General Public License for more details. 1700 | 1701 | You should have received a copy of the GNU General Public License 1702 | along with this program. If not, see . 1703 | 1704 | Also add information on how to contact you by electronic and paper mail. 1705 | 1706 | If the program does terminal interaction, make it output a short 1707 | notice like this when it starts in an interactive mode: 1708 | 1709 | Copyright (C) 1710 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 1711 | This is free software, and you are welcome to redistribute it 1712 | under certain conditions; type `show c' for details. 1713 | 1714 | The hypothetical commands `show w' and `show c' should show the appropriate 1715 | parts of the General Public License. Of course, your program's commands 1716 | might be different; for a GUI interface, you would use an "about box". 1717 | 1718 | You should also get your employer (if you work as a programmer) or school, 1719 | if any, to sign a "copyright disclaimer" for the program, if necessary. 1720 | For more information on this, and how to apply and follow the GNU GPL, see 1721 | . 1722 | 1723 | The GNU General Public License does not permit incorporating your program 1724 | into proprietary programs. If your program is a subroutine library, you 1725 | may consider it more useful to permit linking proprietary applications with 1726 | the library. If this is what you want to do, use the GNU Lesser General 1727 | Public License instead of this License. But first, please read 1728 | . 1729 | 1730 | The complete text of the Apache 2.0 License is as follows: 1731 | 1732 | Apache License 1733 | Version 2.0, January 2004 1734 | http://www.apache.org/licenses/ 1735 | 1736 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1737 | 1738 | 1. Definitions. 1739 | 1740 | "License" shall mean the terms and conditions for use, reproduction, 1741 | and distribution as defined by Sections 1 through 9 of this document. 1742 | 1743 | "Licensor" shall mean the copyright owner or entity authorized by 1744 | the copyright owner that is granting the License. 1745 | 1746 | "Legal Entity" shall mean the union of the acting entity and all 1747 | other entities that control, are controlled by, or are under common 1748 | control with that entity. For the purposes of this definition, 1749 | "control" means (i) the power, direct or indirect, to cause the 1750 | direction or management of such entity, whether by contract or 1751 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 1752 | outstanding shares, or (iii) beneficial ownership of such entity. 1753 | 1754 | "You" (or "Your") shall mean an individual or Legal Entity 1755 | exercising permissions granted by this License. 1756 | 1757 | "Source" form shall mean the preferred form for making modifications, 1758 | including but not limited to software source code, documentation 1759 | source, and configuration files. 1760 | 1761 | "Object" form shall mean any form resulting from mechanical 1762 | transformation or translation of a Source form, including but 1763 | not limited to compiled object code, generated documentation, 1764 | and conversions to other media types. 1765 | 1766 | "Work" shall mean the work of authorship, whether in Source or 1767 | Object form, made available under the License, as indicated by a 1768 | copyright notice that is included in or attached to the work 1769 | (an example is provided in the Appendix below). 1770 | 1771 | "Derivative Works" shall mean any work, whether in Source or Object 1772 | form, that is based on (or derived from) the Work and for which the 1773 | editorial revisions, annotations, elaborations, or other modifications 1774 | represent, as a whole, an original work of authorship. For the purposes 1775 | of this License, Derivative Works shall not include works that remain 1776 | separable from, or merely link (or bind by name) to the interfaces of, 1777 | the Work and Derivative Works thereof. 1778 | 1779 | "Contribution" shall mean any work of authorship, including 1780 | the original version of the Work and any modifications or additions 1781 | to that Work or Derivative Works thereof, that is intentionally 1782 | submitted to Licensor for inclusion in the Work by the copyright owner 1783 | or by an individual or Legal Entity authorized to submit on behalf of 1784 | the copyright owner. For the purposes of this definition, "submitted" 1785 | means any form of electronic, verbal, or written communication sent 1786 | to the Licensor or its representatives, including but not limited to 1787 | communication on electronic mailing lists, source code control systems, 1788 | and issue tracking systems that are managed by, or on behalf of, the 1789 | Licensor for the purpose of discussing and improving the Work, but 1790 | excluding communication that is conspicuously marked or otherwise 1791 | designated in writing by the copyright owner as "Not a Contribution." 1792 | 1793 | "Contributor" shall mean Licensor and any individual or Legal Entity 1794 | on behalf of whom a Contribution has been received by Licensor and 1795 | subsequently incorporated within the Work. 1796 | 1797 | 2. Grant of Copyright License. Subject to the terms and conditions of 1798 | this License, each Contributor hereby grants to You a perpetual, 1799 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 1800 | copyright license to reproduce, prepare Derivative Works of, 1801 | publicly display, publicly perform, sublicense, and distribute the 1802 | Work and such Derivative Works in Source or Object form. 1803 | 1804 | 3. Grant of Patent License. Subject to the terms and conditions of 1805 | this License, each Contributor hereby grants to You a perpetual, 1806 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 1807 | (except as stated in this section) patent license to make, have made, 1808 | use, offer to sell, sell, import, and otherwise transfer the Work, 1809 | where such license applies only to those patent claims licensable 1810 | by such Contributor that are necessarily infringed by their 1811 | Contribution(s) alone or by combination of their Contribution(s) 1812 | with the Work to which such Contribution(s) was submitted. If You 1813 | institute patent litigation against any entity (including a 1814 | cross-claim or counterclaim in a lawsuit) alleging that the Work 1815 | or a Contribution incorporated within the Work constitutes direct 1816 | or contributory patent infringement, then any patent licenses 1817 | granted to You under this License for that Work shall terminate 1818 | as of the date such litigation is filed. 1819 | 1820 | 4. Redistribution. You may reproduce and distribute copies of the 1821 | Work or Derivative Works thereof in any medium, with or without 1822 | modifications, and in Source or Object form, provided that You 1823 | meet the following conditions: 1824 | 1825 | (a) You must give any other recipients of the Work or 1826 | Derivative Works a copy of this License; and 1827 | 1828 | (b) You must cause any modified files to carry prominent notices 1829 | stating that You changed the files; and 1830 | 1831 | (c) You must retain, in the Source form of any Derivative Works 1832 | that You distribute, all copyright, patent, trademark, and 1833 | attribution notices from the Source form of the Work, 1834 | excluding those notices that do not pertain to any part of 1835 | the Derivative Works; and 1836 | 1837 | (d) If the Work includes a "NOTICE" text file as part of its 1838 | distribution, then any Derivative Works that You distribute must 1839 | include a readable copy of the attribution notices contained 1840 | within such NOTICE file, excluding those notices that do not 1841 | pertain to any part of the Derivative Works, in at least one 1842 | of the following places: within a NOTICE text file distributed 1843 | as part of the Derivative Works; within the Source form or 1844 | documentation, if provided along with the Derivative Works; or, 1845 | within a display generated by the Derivative Works, if and 1846 | wherever such third-party notices normally appear. The contents 1847 | of the NOTICE file are for informational purposes only and 1848 | do not modify the License. You may add Your own attribution 1849 | notices within Derivative Works that You distribute, alongside 1850 | or as an addendum to the NOTICE text from the Work, provided 1851 | that such additional attribution notices cannot be construed 1852 | as modifying the License. 1853 | 1854 | You may add Your own copyright statement to Your modifications and 1855 | may provide additional or different license terms and conditions 1856 | for use, reproduction, or distribution of Your modifications, or 1857 | for any such Derivative Works as a whole, provided Your use, 1858 | reproduction, and distribution of the Work otherwise complies with 1859 | the conditions stated in this License. 1860 | 1861 | 5. Submission of Contributions. Unless You explicitly state otherwise, 1862 | any Contribution intentionally submitted for inclusion in the Work 1863 | by You to the Licensor shall be under the terms and conditions of 1864 | this License, without any additional terms or conditions. 1865 | Notwithstanding the above, nothing herein shall supersede or modify 1866 | the terms of any separate license agreement you may have executed 1867 | with Licensor regarding such Contributions. 1868 | 1869 | 6. Trademarks. This License does not grant permission to use the trade 1870 | names, trademarks, service marks, or product names of the Licensor, 1871 | except as required for reasonable and customary use in describing the 1872 | origin of the Work and reproducing the content of the NOTICE file. 1873 | 1874 | 7. Disclaimer of Warranty. Unless required by applicable law or 1875 | agreed to in writing, Licensor provides the Work (and each 1876 | Contributor provides its Contributions) on an "AS IS" BASIS, 1877 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1878 | implied, including, without limitation, any warranties or conditions 1879 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 1880 | PARTICULAR PURPOSE. You are solely responsible for determining the 1881 | appropriateness of using or redistributing the Work and assume any 1882 | risks associated with Your exercise of permissions under this License. 1883 | 1884 | 8. Limitation of Liability. In no event and under no legal theory, 1885 | whether in tort (including negligence), contract, or otherwise, 1886 | unless required by applicable law (such as deliberate and grossly 1887 | negligent acts) or agreed to in writing, shall any Contributor be 1888 | liable to You for damages, including any direct, indirect, special, 1889 | incidental, or consequential damages of any character arising as a 1890 | result of this License or out of the use or inability to use the 1891 | Work (including but not limited to damages for loss of goodwill, 1892 | work stoppage, computer failure or malfunction, or any and all 1893 | other commercial damages or losses), even if such Contributor 1894 | has been advised of the possibility of such damages. 1895 | 1896 | 9. Accepting Warranty or Additional Liability. While redistributing 1897 | the Work or Derivative Works thereof, You may choose to offer, 1898 | and charge a fee for, acceptance of support, warranty, indemnity, 1899 | or other liability obligations and/or rights consistent with this 1900 | License. However, in accepting such obligations, You may act only 1901 | on Your own behalf and on Your sole responsibility, not on behalf 1902 | of any other Contributor, and only if You agree to indemnify, 1903 | defend, and hold each Contributor harmless for any liability 1904 | incurred by, or claims asserted against, such Contributor by reason 1905 | of your accepting any such warranty or additional liability. 1906 | 1907 | END OF TERMS AND CONDITIONS 1908 | 1909 | APPENDIX: How to apply the Apache License to your work. 1910 | 1911 | To apply the Apache License to your work, attach the following 1912 | boilerplate notice, with the fields enclosed by brackets "[]" 1913 | replaced with your own identifying information. (Don't include 1914 | the brackets!) The text should be enclosed in the appropriate 1915 | comment syntax for the file format. We also recommend that a 1916 | file or class name and description of purpose be included on the 1917 | same "printed page" as the copyright notice for easier 1918 | identification within third-party archives. 1919 | 1920 | Copyright [yyyy] [name of copyright owner] 1921 | 1922 | Licensed under the Apache License, Version 2.0 (the "License"); 1923 | you may not use this file except in compliance with the License. 1924 | You may obtain a copy of the License at 1925 | 1926 | http://www.apache.org/licenses/LICENSE-2.0 1927 | 1928 | Unless required by applicable law or agreed to in writing, software 1929 | distributed under the License is distributed on an "AS IS" BASIS, 1930 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1931 | See the License for the specific language governing permissions and 1932 | limitations under the License. 1933 | 1934 | The complete text of the BSD license can be is as follows: 1935 | 1936 | Copyright (c) The Regents of the University of California. 1937 | All rights reserved. 1938 | 1939 | Redistribution and use in source and binary forms, with or without 1940 | modification, are permitted provided that the following conditions 1941 | are met: 1942 | 1. Redistributions of source code must retain the above copyright 1943 | notice, this list of conditions and the following disclaimer. 1944 | 2. Redistributions in binary form must reproduce the above copyright 1945 | notice, this list of conditions and the following disclaimer in the 1946 | documentation and/or other materials provided with the distribution. 1947 | 3. Neither the name of the University nor the names of its contributors 1948 | may be used to endorse or promote products derived from this software 1949 | without specific prior written permission. 1950 | 1951 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1952 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1953 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1954 | ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 1955 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1956 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1957 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1958 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1959 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1960 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1961 | SUCH DAMAGE. 1962 | 1963 | The complete text of the Apache Software License Version 1.1 is as follows: 1964 | 1965 | /* 1966 | * ================================================================ 1967 | * The Apache Software License, Version 1.1 1968 | * ================================================================ 1969 | * 1970 | * Copyright (C) 2000-2002 The Apache Software Foundation. All 1971 | * rights reserved. 1972 | * 1973 | * Redistribution and use in source and binary forms, with or without 1974 | * modification, are permitted provided that the following 1975 | * conditions are met: 1976 | * 1977 | * 1. Redistributions of source code must retain the above copyright 1978 | * notice, this list of conditions and the following disclaimer. 1979 | * 1980 | * 2. Redistributions in binary form must reproduce the above copyright 1981 | * notice, this list of conditions and the following disclaimer in 1982 | * the documentation and/or other materials provided with the 1983 | * distribution. 1984 | * 1985 | * 3. The end-user documentation included with the redistribution, if 1986 | * any, must include the following acknowledgment: "This product 1987 | * includes software developed by the Apache Software Foundation 1988 | * (http://www.apache.org/)." Alternately, this acknowledgment may 1989 | * appear in the software itself, if and wherever such third-party 1990 | * acknowledgments normally appear. 1991 | * 1992 | * 4. The names "Ant" and "Apache Software Foundation" must not be 1993 | * used to endorse or promote products derived from this software 1994 | * without prior written permission. For written permission, please 1995 | * contact apache@apache.org. 1996 | * 1997 | * 5. Products derived from this software may not be called "Apache", 1998 | * nor may "Apache" appear in their name, without prior written 1999 | * permission of the Apache Software Foundation. 2000 | * 2001 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 2002 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2003 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 2004 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION 2005 | * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2006 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2007 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2008 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 2009 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 2010 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 2011 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 2012 | * OF SUCH DAMAGE. 2013 | * 2014 | * This software consists of voluntary contributions made by many 2015 | * individuals on behalf of the Apache Software Foundation. For more 2016 | * information on the Apache Software Foundation, please see 2017 | * . 2018 | * 2019 | */ 2020 | 2021 | The complete text of the MIT license is as follows: 2022 | 2023 | Permission is hereby granted, free of charge, to any person 2024 | obtaining a copy of this software and associated documentation 2025 | files (the “Software”), to deal in the Software without 2026 | restriction, including without limitation the rights to use, 2027 | copy, modify, merge, publish, distribute, sublicense, and/or sell 2028 | copies of the Software, and to permit persons to whom the 2029 | Software is furnished to do so, subject to the following 2030 | conditions: 2031 | 2032 | The above copyright notice and this permission notice shall be 2033 | included in all copies or substantial portions of the Software. 2034 | 2035 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, 2036 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 2037 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2038 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 2039 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 2040 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2041 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2042 | OTHER DEALINGS IN THE SOFTWARE. 2043 | 2044 | The complete text of the Eclipse Public License v1.0 is as follows: 2045 | 2046 | Eclipse Public License - v 1.0 2047 | 2048 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2049 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 2050 | CONSTITUTES RECIPIENT’S ACCEPTANCE OF THIS AGREEMENT. 2051 | 2052 | 1. DEFINITIONS 2053 | 2054 | "Contribution" means: 2055 | 2056 | a) in the case of the initial Contributor, the initial code and documentation 2057 | distributed under this Agreement, and 2058 | b) in the case of each subsequent Contributor: 2059 | 2060 | i) changes to the Program, and 2061 | 2062 | ii) additions to the Program; 2063 | 2064 | where such changes and/or additions to the Program originate from and are 2065 | distributed by that particular Contributor. A Contribution 'originates' from a 2066 | Contributor if it was added to the Program by such Contributor itself or anyone 2067 | acting on such Contributor’s behalf. Contributions do not include additions to 2068 | the Program which: (i) are separate modules of software distributed in 2069 | conjunction with the Program under their own license agreement, and (ii) are not 2070 | derivative works of the Program. 2071 | 2072 | "Contributor" means any person or entity that distributes the Program. 2073 | 2074 | "Licensed Patents " mean patent claims licensable by a Contributor which are 2075 | necessarily infringed by the use or sale of its Contribution alone or when 2076 | combined with the Program. 2077 | 2078 | "Program" means the Contributions distributed in accordance with this Agreement. 2079 | 2080 | "Recipient" means anyone who receives the Program under this Agreement, 2081 | including all Contributors. 2082 | 2083 | 2. GRANT OF RIGHTS 2084 | 2085 | a) Subject to the terms of this Agreement, each Contributor hereby grants 2086 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 2087 | reproduce, prepare derivative works of, publicly display, publicly perform, 2088 | distribute and sublicense the Contribution of such Contributor, if any, and such 2089 | derivative works, in source code and object code form. 2090 | 2091 | b) Subject to the terms of this Agreement, each Contributor hereby grants 2092 | Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed 2093 | Patents to make, use, sell, offer to sell, import and otherwise transfer the 2094 | Contribution of such Contributor, if any, in source code and object code form. 2095 | This patent license shall apply to the combination of the Contribution and the 2096 | Program if, at the time the Contribution is added by the Contributor, such 2097 | addition of the Contribution causes such combination to be covered by the 2098 | Licensed Patents. The patent license shall not apply to any other combinations 2099 | which include the Contribution. No hardware per se is licensed hereunder. 2100 | 2101 | c) Recipient understands that although each Contributor grants the licenses to 2102 | its Contributions set forth herein, no assurances are provided by any 2103 | Contributor that the Program does not infringe the patent or other intellectual 2104 | property rights of any other entity. Each Contributor disclaims any liability to 2105 | Recipient for claims brought by any other entity based on infringement of 2106 | intellectual property rights or otherwise. As a condition to exercising the 2107 | rights and licenses granted hereunder, each Recipient hereby assumes sole 2108 | responsibility to secure any other intellectual property rights needed, if any. 2109 | For example, if a third party patent license is required to allow Recipient to 2110 | distribute the Program, it is Recipient’s responsibility to acquire that license 2111 | before distributing the Program. 2112 | 2113 | d) Each Contributor represents that to its knowledge it has sufficient copyright 2114 | rights in its Contribution, if any, to grant the copyright license set forth in 2115 | this Agreement. 2116 | 2117 | 3. REQUIREMENTS 2118 | 2119 | A Contributor may choose to distribute the Program in object code form under its 2120 | own license agreement, provided that: 2121 | 2122 | a) it complies with the terms and conditions of this Agreement; and 2123 | 2124 | b) its license agreement: 2125 | 2126 | i) effectively disclaims on behalf of all Contributors all warranties and 2127 | conditions, express and implied, including warranties or conditions of title and 2128 | non-infringement, and implied warranties or conditions of merchantability and 2129 | fitness for a particular purpose; 2130 | 2131 | ii) effectively excludes on behalf of all Contributors all liability for 2132 | damages, including direct, indirect, special, incidental and consequential 2133 | damages, such as lost profits; 2134 | 2135 | iii) states that any provisions which differ from this Agreement are offered by 2136 | that Contributor alone and not by any other party; and 2137 | 2138 | iv) states that source code for the Program is available from such Contributor, 2139 | and informs licensees how to obtain it in a reasonable manner on or through a 2140 | medium customarily used for software exchange. 2141 | 2142 | When the Program is made available in source code form: 2143 | 2144 | a) it must be made available under this Agreement; and 2145 | b) a copy of this Agreement must be included with each copy of the Program. 2146 | 2147 | Contributors may not remove or alter any copyright notices contained within the 2148 | Program. 2149 | 2150 | Each Contributor must identify itself as the originator of its Contribution, if 2151 | any, in a manner that reasonably allows subsequent Recipients to identify the 2152 | originator of the Contribution. 2153 | 2154 | 4. COMMERCIAL DISTRIBUTION 2155 | 2156 | Commercial distributors of software may accept certain responsibilities with 2157 | respect to end users, business partners and the like. While this license is 2158 | intended to facilitate the commercial use of the Program, the Contributor who 2159 | includes the Program in a commercial product offering should do so in a manner 2160 | which does not create potential liability for other Contributors. Therefore, if 2161 | a Contributor includes the Program in a commercial product offering, such 2162 | Contributor ("Commercial Contributor") hereby agrees to defend and indemnify 2163 | every other Contributor ("Indemnified Contributor") against any losses, damages 2164 | and costs (collectively "Losses") arising from claims, lawsuits and other legal 2165 | actions brought by a third party against the Indemnified Contributor to the 2166 | extent caused by the acts or omissions of such Commercial Contributor in 2167 | connection with its distribution of the Program in a commercial product 2168 | offering. The obligations in this section do not apply to any claims or Losses 2169 | relating to any actual or alleged intellectual property infringement. In order 2170 | to qualify, an Indemnified Contributor must: a) promptly notify the Commercial 2171 | Contributor in writing of such claim, and b) allow the Commercial Contributor to 2172 | control, and cooperate with the Commercial Contributor in, the defense and any 2173 | related settlement negotiations. The Indemnified Contributor may participate in 2174 | any such claim at its own expense. 2175 | 2176 | For example, a Contributor might include the Program in a commercial product 2177 | offering, Product X. That Contributor is then a Commercial Contributor. If that 2178 | Commercial Contributor then makes performance claims, or offers warranties 2179 | related to Product X, those performance claims and warranties are such 2180 | Commercial Contributor’s responsibility alone. Under this section, the 2181 | Commercial Contributor would have to defend claims against the other 2182 | Contributors related to those performance claims and warranties, and if a court 2183 | requires any other Contributor to pay any damages as a result, the Commercial 2184 | Contributor must pay those damages. 2185 | 2186 | 5. NO WARRANTY 2187 | 2188 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN 2189 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 2190 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, 2191 | NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each 2192 | Recipient is solely responsible for determining the appropriateness of using and 2193 | distributing the Program and assumes all risks associated with its exercise of 2194 | rights under this Agreement , including but not limited to the risks and costs 2195 | of program errors, compliance with applicable laws, damage to or loss of data, 2196 | programs or equipment, and unavailability or interruption of operations. 2197 | 2198 | 6. DISCLAIMER OF LIABILITY 2199 | 2200 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 2201 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2202 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST 2203 | PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 2204 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2205 | OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS 2206 | GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 2207 | 2208 | 7. GENERAL 2209 | 2210 | If any provision of this Agreement is invalid or unenforceable under applicable 2211 | law, it shall not affect the validity or enforceability of the remainder of the 2212 | terms of this Agreement, and without further action by the parties hereto, such 2213 | provision shall be reformed to the minimum extent necessary to make such 2214 | provision valid and enforceable. 2215 | 2216 | If Recipient institutes patent litigation against any entity (including a 2217 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 2218 | (excluding combinations of the Program with other software or hardware) 2219 | infringes such Recipient’s patent(s), then such Recipient’s rights granted under 2220 | Section 2(b) shall terminate as of the date such litigation is filed. 2221 | 2222 | All Recipient’s rights under this Agreement shall terminate if it fails to 2223 | comply with any of the material terms or conditions of this Agreement and does 2224 | not cure such failure in a reasonable period of time after becoming aware of 2225 | such noncompliance. If all Recipient’s rights under this Agreement terminate, 2226 | Recipient agrees to cease use and distribution of the Program as soon as 2227 | reasonably practicable. However, Recipient’s obligations under this Agreement 2228 | and any licenses granted by Recipient relating to the Program shall continue and 2229 | survive. 2230 | 2231 | Everyone is permitted to copy and distribute copies of this Agreement, but in 2232 | order to avoid inconsistency the Agreement is copyrighted and may only be 2233 | modified in the following manner. The Agreement Steward reserves the right to 2234 | publish new versions (including revisions) of this Agreement from time to time. 2235 | No one other than the Agreement Steward has the right to modify this Agreement. 2236 | The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation 2237 | may assign the responsibility to serve as the Agreement Steward to a suitable 2238 | separate entity. Each new version of the Agreement will be given a 2239 | distinguishing version number. The Program (including Contributions) may always 2240 | be distributed subject to the version of the Agreement under which it was 2241 | received. In addition, after a new version of the Agreement is published, 2242 | Contributor may elect to distribute the Program (including its Contributions) 2243 | under the new version. Except as expressly stated in Sections 2(a) and 2(b) 2244 | above, Recipient receives no rights or licenses to the intellectual property of 2245 | any Contributor under this Agreement, whether expressly, by implication, 2246 | estoppel or otherwise. All rights in the Program not expressly granted under 2247 | this Agreement are reserved. 2248 | 2249 | This Agreement is governed by the laws of the State of New York and the 2250 | intellectual property laws of the United States of America. No party to this 2251 | Agreement will bring a legal action under this Agreement more than one year 2252 | after the cause of action arose. Each party waives its rights to a jury trial in 2253 | any resulting litigation. 2254 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JRuby-Lint 2 | 3 | See how ready your Ruby code is to run on JRuby. 4 | 5 | JRuby-Lint is a simple tool that allows you to check your project code 6 | and configuration for common gotchas and issues that might make it 7 | difficult to run your code on JRuby. 8 | 9 | ## Usage 10 | 11 | JRuby-Lint requires JRuby to run. So, [install JRuby first][install] 12 | if you already haven't, then `gem install jruby-lint`. 13 | 14 | Then simply run `jrlint` in your project to receive a report of 15 | places in your project where you should investigate further. 16 | 17 | ## Checks 18 | 19 | Here is a list of the current checks implemented: 20 | 21 | - Report usage of ObjectSpace.each_object and ObjectSpace._id2ref 22 | which are expensive and disabled by default 23 | - Report usage of Thread.critical, which is discouraged in favor of a 24 | plain Mutex. 25 | - Report known gems and libraries that use C extensions and try to 26 | provide known alternatives (Live data retrieved from https://github.com/jruby/jruby/wiki/C-Extension-Alternatives). 27 | - Report usage of Kernel#fork (which does not work). 28 | - Report behavior difference when using system('ruby'), which launches 29 | the command in-process in a new copy of the interpreter for speed 30 | 31 | ## Reports 32 | 33 | JRuby-lint supports text and html reports. Run jrlint with the option --html 34 | to generate an html report with the results. 35 | 36 | ## TODO 37 | 38 | Here is a list of checks and options we'd like to implement: 39 | 40 | - Report on more threading and concurrency issues/antipatterns 41 | - arr.each {|x| arr.delete(x) } 42 | - Try to detect IO/File resource usage without blocks 43 | - Check .gemspec files for extensions and extconf.rb for 44 | #create_makefile and warn about compiliing C extensions 45 | - Check whether Rails production.rb contains `config.threadsafe!` 46 | - Detect ERB files and skip them, or... 47 | - Detect ERB files and pre-process them to Ruby source with Erubis 48 | - Detect Bundler gems that have a `platforms` qualifier and ignore 49 | "platforms :ruby" 50 | - Change to use jruby-parser 51 | - Allow use of a comment marker to suppress individual checks 52 | 53 | ### Further Down the Road 54 | 55 | - Arbitrary method/AST search functionality 56 | - Code rewriter: option to change code automatically where it's 57 | feasible 58 | - Revive or build an isit.jruby.org site for tracking 59 | - Make JRuby-Lint submit results to tracking site based on lint passes 60 | and/or test suite runs 61 | 62 | [install]: http://jruby.org/getting-started 63 | 64 | ## License 65 | 66 | JRuby-Lint is Copyright (c) 2007-2013 The JRuby project, and is released 67 | under a tri EPL/GPL/LGPL license. You can use it, redistribute it 68 | and/or modify it under the terms of the: 69 | 70 | Eclipse Public License version 1.0 71 | GNU General Public License version 2 72 | GNU Lesser General Public License version 2.1 73 | 74 | See the file `LICENSE.txt` in distribution for details. 75 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler' 2 | Bundler::GemHelper.install_tasks 3 | 4 | require 'bundler/setup' 5 | require 'rspec/core/rake_task' 6 | ENV['RUN_ALL_SPECS'] = 'true' # Always run all specs from Rake 7 | RSpec::Core::RakeTask.new 8 | 9 | task :default => [:update_fixtures, :spec] 10 | 11 | require 'rake/clean' 12 | require 'open-uri' 13 | require 'net/https' 14 | 15 | file "spec/fixtures/C-Extension-Alternatives.html" do |t| 16 | require 'jruby/lint/libraries' 17 | cache = JRuby::Lint::Libraries::Cache.new('spec/fixtures') 18 | cache.fetch("C-Extension-Alternatives") 19 | end 20 | 21 | fixtures = ["spec/fixtures/C-Extension-Alternatives.html"] 22 | task :update_fixtures => fixtures 23 | 24 | CLOBBER.push *fixtures 25 | -------------------------------------------------------------------------------- /bin/jrlint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'jruby/lint/cli' 4 | 5 | JRuby::Lint::CLI.new(ARGV).run 6 | -------------------------------------------------------------------------------- /jruby-lint.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | $:.push File.expand_path("../lib", __FILE__) 3 | require "jruby/lint/version" 4 | 5 | Gem::Specification.new do |s| 6 | s.name = "jruby-lint" 7 | s.version = JRuby::Lint::VERSION 8 | s.platform = Gem::Platform::RUBY 9 | s.required_ruby_version = '>= 2.5.3' 10 | s.authors = ["Nick Sieger"] 11 | s.email = ["nick@nicksieger.com"] 12 | s.licenses = ["EPL-1.0", "GPL-2.0", "LGPL-2.1"] 13 | s.homepage = "https://github.com/jruby/jruby-lint" 14 | s.summary = %q{See how ready your Ruby code is to run on JRuby.} 15 | s.description = %q{This utility presents hints and suggestions to 16 | give you an idea of potentially troublesome spots in your code and 17 | dependencies that keep your code from running efficiently on JRuby. 18 | 19 | Most pure Ruby code will run fine, but the two common areas that 20 | trip people up are native extensions and threading} 21 | 22 | s.files = `git ls-files`.split("\n") 23 | s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 24 | s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } 25 | s.require_paths = ["lib"] 26 | 27 | s.add_dependency "term-ansicolor" 28 | s.add_development_dependency "rake" 29 | s.add_development_dependency "rspec", ">= 2.5" 30 | s.add_development_dependency "rspec-given" 31 | s.add_development_dependency "aruba" 32 | end 33 | 34 | # Local Variables: 35 | # mode: ruby 36 | # End: 37 | -------------------------------------------------------------------------------- /lib/jruby/lint.rb: -------------------------------------------------------------------------------- 1 | begin 2 | require 'jruby' 3 | rescue LoadError 4 | raise LoadError, 'JRuby-Lint must be run under JRuby' 5 | end 6 | 7 | module JRuby 8 | module Lint 9 | end 10 | end 11 | 12 | require 'jruby/lint/ast' 13 | require 'jruby/lint/project' 14 | require 'jruby/lint/finding' 15 | require 'jruby/lint/libraries' 16 | require 'jruby/lint/collectors' 17 | require 'jruby/lint/checkers' 18 | require 'jruby/lint/reporters' 19 | require 'jruby/lint/version' 20 | -------------------------------------------------------------------------------- /lib/jruby/lint/ast.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | module AST 3 | module MethodCalls 4 | def visitCallNode(node) 5 | visitMethodCallNode(node) 6 | end 7 | 8 | def visitFCallNode(node) 9 | visitMethodCallNode(node) 10 | end 11 | 12 | def visitVCallNode(node) 13 | visitMethodCallNode(node) 14 | end 15 | 16 | def visitAttrAssignNode(node) 17 | visitMethodCallNode(node) 18 | end 19 | end 20 | 21 | module Helpers 22 | def find_first(node, &block) 23 | descendants(node).detect(&block) 24 | end 25 | 26 | def descendants(node) 27 | children = node.child_nodes 28 | children.empty? ? [node] : children.map {|n| [n] + descendants(n) }.flatten 29 | end 30 | end 31 | 32 | class Visitor 33 | include Enumerable 34 | include org.jruby.ast.visitor.NodeVisitor 35 | attr_reader :ast, :stack 36 | 37 | def initialize(ast) 38 | @ast = ast 39 | end 40 | 41 | def each(&block) 42 | @block = block 43 | ast.accept(self) 44 | ensure 45 | @block = nil 46 | end 47 | 48 | alias each_node each 49 | alias traverse each 50 | 51 | def visit(method, node) 52 | @block.call(node) if @block 53 | node.child_nodes.each do |cn| 54 | cn.accept(self) rescue nil 55 | end 56 | end 57 | 58 | def method_missing(name, *args, &block) 59 | if name.to_s =~ /^visit/ 60 | visit(name, *args) 61 | else 62 | super 63 | end 64 | end 65 | end 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /lib/jruby/lint/checkers.rb: -------------------------------------------------------------------------------- 1 | # Any class with this module included in it will be loaded as a 2 | # checker. 3 | module JRuby::Lint 4 | module Checker 5 | def self.included(cls) 6 | loaded_checkers << cls 7 | end 8 | 9 | def self.loaded_checkers 10 | @checkers ||= [] 11 | end 12 | 13 | # Note: for parentage methods below -1 is current visited, -2 is parent ,... 14 | 15 | ## 16 | # What is parent during visit of the current node being visited. 17 | def parent 18 | collector.stack.size >= 2 ? collector.stack[-2] : nil 19 | end 20 | 21 | def grand_parent 22 | collector.stack.size >= 3 ? collector.stack[-3] : nil 23 | end 24 | 25 | ## 26 | # source line with line node provides 27 | def src_line(line) 28 | collector.contents.split(/\n/)[line] 29 | end 30 | 31 | attr_accessor :collector 32 | end 33 | 34 | module Checkers 35 | end 36 | end 37 | 38 | require 'jruby/lint/checkers/fork_exec' 39 | require 'jruby/lint/checkers/gem' 40 | require 'jruby/lint/checkers/gemspec' 41 | require 'jruby/lint/checkers/thread_critical' 42 | require 'jruby/lint/checkers/object_space' 43 | require 'jruby/lint/checkers/system' 44 | require 'jruby/lint/checkers/nonatomic' 45 | -------------------------------------------------------------------------------- /lib/jruby/lint/checkers/fork_exec.rb: -------------------------------------------------------------------------------- 1 | class JRuby::Lint::Checkers::ForkExec 2 | include JRuby::Lint::Checker 3 | 4 | def visitCallNode(node) 5 | if fork?(node) 6 | @call_node = node 7 | child = node.child_nodes.first 8 | if child && %w(COLON3NODE CONSTNODE).include?(child.node_type.to_s) && child.name == :Kernel 9 | add_finding(node) 10 | end 11 | proc { @call_node = nil } 12 | end 13 | end 14 | 15 | def visitFCallNode(node) 16 | add_finding node if fork?(node) 17 | end 18 | 19 | def visitVCallNode(node) 20 | add_finding node if fork?(node) && !@call_node 21 | end 22 | 23 | def fork?(node) 24 | node.name == :fork 25 | end 26 | 27 | def add_finding(node) 28 | collector.add_finding('Kernel#fork is not implemented on JRuby.', [:fork, :error], node.line+1) 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/jruby/lint/checkers/gem.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint::Checkers 2 | module CheckGemNode 3 | def self.add_wiki_link_finding(collector) 4 | unless @added_wiki_link 5 | collector.add_finding("For more on gem compatibility see https://github.com/jruby/jruby/wiki/C-Extension-Alternatives", [:gems, :info]).tap do |f| 6 | def f.to_s 7 | message 8 | end 9 | end 10 | @added_wiki_link = true 11 | end 12 | end 13 | 14 | def gem_name(node) 15 | first_arg = node&.args_node&.child_nodes[0] 16 | first_arg.value.to_s if first_arg&.node_type&.to_s == "STRNODE" 17 | end 18 | 19 | def jruby_gem_entry?(node) 20 | node&.args_node&.child_nodes.each do |child| 21 | if child&.node_type&.to_s == "HASHNODE" 22 | child.pairs.each do |pair| 23 | return false if pair.key.name == :platform && 24 | pair.value.name != :jruby 25 | end 26 | end 27 | end 28 | 29 | # platform(:mri, ...) { gem 'rdiscount' } 30 | # FIXME: Esoteric use of platform(...) { group(...) {} } is still broken 31 | if grand_parent.kind_of?(org::jruby::ast::CallNode) && 32 | grand_parent.name == :platforms 33 | grand_parent.args_node.child_nodes.each do |child| 34 | return false if child&.name != :jruby 35 | end 36 | end 37 | 38 | true 39 | end 40 | 41 | def check_gem(collector, call_node) 42 | @gems ||= collector.project.libraries.gems 43 | gem_name = gem_name(call_node) 44 | if gem_name && jruby_gem_entry?(call_node) && instructions = @gems[gem_name] 45 | CheckGemNode.add_wiki_link_finding(collector) 46 | msg = "Found gem '#{gem_name}' which is reported to have some issues:\n#{instructions}" 47 | collector.add_finding(msg, [:gems, :warning], call_node.line+1) 48 | end 49 | end 50 | end 51 | 52 | class Gem 53 | include JRuby::Lint::Checker, CheckGemNode 54 | 55 | def visitFCallNode(node) 56 | check_gem(collector, node) if node.name == :gem 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /lib/jruby/lint/checkers/gemspec.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | module Checkers 3 | class Gemspec 4 | include Checker 5 | include CheckGemNode 6 | include AST::Helpers 7 | 8 | def initialize 9 | @gemspec_block_var = nil 10 | end 11 | 12 | def visitCallNode(node) 13 | # Gem::Specification.new do |s| => 14 | # 15 | # CallNoArgBlockNode |new| 16 | # Colon2ConstNode |Specification| 17 | # IterNode 18 | # DAsgnNode |s| &0 >0 19 | # NilImplicitNode |nil| 20 | # BlockNode 21 | if node.name == :new && # new 22 | node.args_node.nil? && # no args 23 | node.iter_node && # with a block 24 | node.receiver_node.node_type.to_s == "COLON2NODE" && # :: - Colon2 25 | node.receiver_node.name == :Specification && # ::Specification 26 | node.receiver_node.left_node.name == :Gem # Gem::Specification 27 | arg_node = find_first(node.iter_node.var_node) {|n| n.respond_to?(:name) } 28 | @gemspec_block_var = arg_node.name 29 | return proc { @gemspec_block_var = nil } 30 | end 31 | 32 | # s.add_dependency "rdiscount" => 33 | # 34 | # CallOneArgNode |add_dependency| 35 | # DVarNode |s| &0 >0 36 | # ArrayNode 37 | # StrNode =="rdiscount" 38 | if @gemspec_block_var && 39 | node.name == :add_dependency && 40 | node.receiver_node.name == @gemspec_block_var 41 | check_gem(collector, node) 42 | end 43 | rescue 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/jruby/lint/checkers/nonatomic.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | module Checkers 3 | class NonAtomic 4 | include Checker 5 | IVAR = org::jruby::ast::InstVarNode 6 | CVAR = org::jruby::ast::ClassVarNode 7 | 8 | OPERATORS = [:+, :-, :/, :*, :&, :|, :^, :>>, :<<, :%, :**] 9 | 10 | def visitOpAsgnOrNode(node) 11 | @last = node 12 | check_nonatomic(node, node.first_node) 13 | end 14 | 15 | def visitOpAsgnAndNode(node) 16 | @last = node 17 | check_nonatomic(node, node.first_node) 18 | end 19 | 20 | def visitOpElementAsgnNode(node) 21 | name = src_line(node.line).split(node.operator_name + '=', 2)[0].strip 22 | add_finding(collector, node, name) 23 | end 24 | 25 | def visitOpAsgnNode(node) 26 | check_nonatomic(node, node.receiver_node, node.variable_name) 27 | end 28 | 29 | def operator_op_assignment?(node, type) 30 | rhs = node.value_node 31 | rhs.kind_of?(org::jruby::ast::CallNode) && 32 | OPERATORS.include?(rhs.name) && 33 | rhs.receiver_node.kind_of?(type) 34 | end 35 | 36 | def visitInstAsgnNode(node) 37 | if !@last && operator_op_assignment?(node, IVAR) || 38 | @last && parent != @last 39 | check_nonatomic(node, node) 40 | end 41 | @last = nil 42 | end 43 | 44 | def visitClassVarAsgnNode(node) 45 | if !@last && operator_op_assignment?(node, CVAR) || 46 | @last && parent != @last 47 | check_nonatomic(node, node) 48 | end 49 | @last = nil 50 | end 51 | 52 | def check_nonatomic(orig_node, risk_node, name=nil) 53 | case risk_node 54 | when org::jruby::ast::LocalVarNode, 55 | org::jruby::ast::DVarNode 56 | # ok...mostly-safe cases 57 | false 58 | else 59 | add_finding(collector, orig_node, name || risk_node.name) 60 | true 61 | end 62 | end 63 | 64 | def add_finding(collector, node, name) 65 | collector.add_finding("Non-local operator assignment (#{name}) is not guaranteed to be atomic.", [:nonatomic, :warning], node.line+1) 66 | end 67 | end 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /lib/jruby/lint/checkers/object_space.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | module Checkers 3 | class ObjectSpace 4 | include Checker 5 | METHODS = [:each_object, :_id2ref] 6 | OK_ARGS = [:Class, :Module] 7 | 8 | def visitCallNode(node) 9 | if METHODS.include?(node.name) 10 | begin 11 | return unless node.receiver_node.node_type.to_s == "CONSTNODE" && 12 | node.receiver_node.name == :ObjectSpace 13 | return if node.args_node && node.args_node.size == 1 && 14 | OK_ARGS.include?(node.args_node.first.name) 15 | add_finding(collector, node) 16 | rescue 17 | end 18 | end 19 | end 20 | 21 | def add_finding(collector, node) 22 | collector.add_finding("Use of ObjectSpace is expensive and disabled by default. Use -X+O to enable.", 23 | [:objectspace, :warning], node.line+1) 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/jruby/lint/checkers/system.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | module Checkers 3 | class System 4 | include Checker 5 | 6 | # Make sure to follow all Kernel.system calls 7 | def visitCallNode(node) 8 | if node.name == :system || node.name == :'`' 9 | @call_node = node 10 | add_finding(node) if red_flag?(node) 11 | proc { @call_node = nil } 12 | end 13 | end 14 | 15 | # Visits the function calls for system 16 | def visitFCallNode(node) 17 | if node.name == :system 18 | add_finding(node) if red_flag?(node) 19 | end 20 | end 21 | 22 | def add_finding(node) 23 | collector.add_finding("Calling Kernel.system('ruby ...') will get called in-process. Sometimes this works differently than expected", 24 | [:system, :warning], node.line+1) 25 | end 26 | 27 | # Defines red_flag when argument matches ruby 28 | def red_flag?(node) 29 | first_arg = node.args_node.child_nodes.first 30 | first_arg && first_arg.node_type.to_s == "STRNODE" && ruby_executable?(first_arg) 31 | end 32 | 33 | def ruby_executable?(node) 34 | match_on = Regexp.union([/.*ruby$/i, /.*j?irb$/i, /\.rb$/i]) 35 | node.value.split.first =~ match_on 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/jruby/lint/checkers/thread_critical.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | module Checkers 3 | class ThreadCritical 4 | include Checker 5 | 6 | METHODS = [:critical, :critical=] 7 | 8 | def visitCallNode(node) 9 | if METHODS.include?(node.name) 10 | begin 11 | if node.receiver_node.node_type.to_s == "CONSTNODE" && node.receiver_node.name == :Thread 12 | add_finding(collector, node) 13 | end 14 | rescue 15 | end 16 | end 17 | end 18 | alias visitAttrAssignNode visitCallNode 19 | 20 | def add_finding(collector, node) 21 | collector.add_finding("Use of Thread.critical is discouraged. Use a Mutex instead.", 22 | [:threads, :warning], node.line+1) 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/jruby/lint/cli.rb: -------------------------------------------------------------------------------- 1 | module JRuby 2 | module Lint 3 | class CLI 4 | attr_reader :options 5 | 6 | def initialize(args) 7 | process_options(args) 8 | end 9 | 10 | def process_options(args) 11 | require 'optparse' 12 | require 'ostruct' 13 | @options = OpenStruct.new 14 | OptionParser.new do |opts| 15 | opts.banner = "Usage: jrlint [options] [files]" 16 | opts.separator "" 17 | opts.separator "Options:" 18 | 19 | opts.on('-C', '--chdir DIRECTORY', "Change working directory") do |v| 20 | Dir.chdir(v) 21 | end 22 | 23 | opts.on("-e", '--eval SCRIPT', "Lint an inline script") do |v| 24 | @options.eval ||= [] 25 | @options.eval << v 26 | end 27 | 28 | opts.on("-t", "--tag TAG", "Report findings tagged with TAG") do |v| 29 | @options.tags ||= [] 30 | @options.tags << v 31 | end 32 | 33 | opts.on('--text', 'print report as text') do 34 | @options.text = true 35 | end 36 | 37 | opts.on('--ansi', 'print report as ansi text') do 38 | @options.ansi = true 39 | end 40 | 41 | opts.on('--no-source-line', 'do not print out line of source') do 42 | @options.no_src_line = true 43 | end 44 | 45 | opts.on('--html [REPORT_FILE]', 'print report as html file') do |file| 46 | @options.html = file || 'jruby-lint.html' 47 | end 48 | 49 | opts.on_tail("-v", "--version", "Print version and exit") do 50 | require 'jruby/lint/version' 51 | puts "JRuby-Lint version #{VERSION}" 52 | exit 53 | end 54 | 55 | opts.on_tail("-h", "--help", "This message") do 56 | puts opts 57 | exit 58 | end 59 | end.parse!(args) 60 | 61 | @options.files = args.empty? ? nil : args 62 | rescue OptionParser::InvalidOption 63 | puts $!.message 64 | exit -1 65 | end 66 | 67 | def run 68 | require 'jruby/lint' 69 | require 'benchmark' 70 | project = JRuby::Lint::Project.new(@options) 71 | 72 | puts "JRuby-Lint version #{JRuby::Lint::VERSION}" 73 | time = Benchmark.realtime { project.run } 74 | term = @options.eval ? 'expression' : 'file' 75 | puts "Processed #{project.files.size} #{term}#{project.files.size == 1 ? '' : 's'} in #{'%0.02f' % time} seconds" 76 | 77 | if project.findings.empty? 78 | puts "OK" 79 | exit 80 | else 81 | puts "Found #{project.findings.count { |e| !e.tags.include? "internal" } } items" 82 | exit 1 83 | end 84 | end 85 | end 86 | end 87 | end 88 | -------------------------------------------------------------------------------- /lib/jruby/lint/collectors.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | class Collector 3 | attr_accessor :checkers, :findings, :project, :contents, :file, :stack 4 | 5 | def initialize(project = nil, file = nil) 6 | @checkers = Checker.loaded_checkers.map(&:new) 7 | @checkers.each {|c| c.collector = self } 8 | @findings = [] 9 | @project, @file = project, file || '' 10 | 11 | # top to bottom list of elements as they are visited 12 | @stack = [] # FIXME: ast visiting is not something checkers can see so stored here for now 13 | end 14 | 15 | def add_finding(message, tags, line=nil) 16 | src_line = line ? contents.split(/\n/)[line-1] : nil 17 | @findings << Finding.new(message, tags, file, line, src_line) 18 | end 19 | 20 | class CheckersVisitor < AST::Visitor 21 | attr_reader :collector, :checkers, :stack 22 | 23 | 24 | def initialize(ast, collector, checkers) 25 | super(ast) 26 | @collector, @checkers = collector, checkers 27 | end 28 | 29 | def visit(method, node) 30 | @collector.stack.push node 31 | after_hooks = [] 32 | checkers.each do |ch| 33 | begin 34 | if ch.respond_to?(method) 35 | res = ch.send(method, node) 36 | after_hooks << res if res.respond_to?(:call) 37 | end 38 | rescue Exception => e 39 | collector.add_finding("Exception while traversing: #{e.message}\n at #{e.backtrace.first}", 40 | [:internal, :debug], node.line+1) 41 | end 42 | end 43 | super 44 | rescue Exception => e 45 | collector.add_finding("Exception while traversing: #{e.message}\n at #{e.backtrace.first}", 46 | [:internal, :debug], node.line+1) 47 | ensure 48 | begin 49 | after_hooks.each {|h| h.call } 50 | rescue 51 | end 52 | @collector.stack.pop 53 | end 54 | end 55 | 56 | def run 57 | begin 58 | CheckersVisitor.new(ast, self, checkers).traverse 59 | rescue SyntaxError => e 60 | file, line, message = e.message.split(/:\s*/, 3) 61 | add_finding(message, [:syntax, :error], line.to_i) 62 | end 63 | end 64 | 65 | def ast 66 | @ast ||= JRuby.parse(contents, file, true) 67 | end 68 | 69 | def contents 70 | @contents || File.read(@file) 71 | end 72 | 73 | def self.inherited(base) 74 | self.all << base 75 | end 76 | 77 | def self.all 78 | @collectors ||= [] 79 | end 80 | end 81 | 82 | module Collectors 83 | end 84 | end 85 | 86 | require 'jruby/lint/collectors/ruby' 87 | require 'jruby/lint/collectors/bundler' 88 | require 'jruby/lint/collectors/rake' 89 | require 'jruby/lint/collectors/gemspec' 90 | -------------------------------------------------------------------------------- /lib/jruby/lint/collectors/bundler.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | module Collectors 3 | class Bundler < Collector 4 | def self.detect?(f) 5 | File.basename(f) == 'Gemfile' 6 | end 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/jruby/lint/collectors/gemspec.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | module Collectors 3 | class Gemspec < Collector 4 | def self.detect?(f) 5 | File.extname(f) == '.gemspec' 6 | end 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/jruby/lint/collectors/rake.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | module Collectors 3 | class Rake < Collector 4 | def self.detect?(f) 5 | File.basename(f) == 'Rakefile' || File.extname(f) == '.rake' 6 | end 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/jruby/lint/collectors/ruby.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | module Collectors 3 | class Ruby < Collector 4 | def initialize(project, file, contents = nil) 5 | super(project, file) 6 | @contents = contents 7 | end 8 | 9 | def self.detect?(f) 10 | File.extname(f) == '.rb' 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/jruby/lint/finding.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | class Finding < Struct.new(:message, :tags, :file, :line, :src_line) 3 | def initialize(*args) 4 | args[1].map! {|x| x.to_s } if args.size > 1 5 | if args.size > 2 && args[2].respond_to?(:file) && args[2].respond_to?(:line) 6 | args = [args[0], args[1], args[2].file, (args[2].line + 1)] 7 | end 8 | super 9 | end 10 | 11 | def error? 12 | tags.include?('error') 13 | end 14 | 15 | def warning? 16 | tags.include?('warning') 17 | end 18 | 19 | def to_s 20 | "#{file}:#{line}: [#{tags.join(', ')}] #{message}" 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/jruby/lint/libraries.rb: -------------------------------------------------------------------------------- 1 | require 'net/https' 2 | require 'tempfile' 3 | require 'fileutils' 4 | 5 | module JRuby::Lint 6 | class Libraries 7 | class Cache 8 | def initialize(cache_dir = nil) 9 | @cache_dir = cache_dir || ENV['JRUBY_LINT_CACHE'] || 10 | (defined?(Gem.user_dir) && File.join(Gem.user_dir, 'lint')) || Dir::tmpdir 11 | FileUtils.mkdir_p(@cache_dir) unless File.directory?(@cache_dir) 12 | end 13 | 14 | def fetch(name) 15 | filename = filename_for(name) 16 | if File.file?(filename) && !stale?(filename) 17 | File.read(filename) 18 | else 19 | read_from_wiki(name, filename) 20 | end 21 | end 22 | 23 | def store(name, content) 24 | File.open(filename_for(name), "w") {|f| f << content } 25 | end 26 | 27 | def filename_for(name) 28 | name = File.basename(name) 29 | File.join(@cache_dir, File.extname(name).empty? ? "#{name}.md" : name) 30 | end 31 | 32 | def stale?(filename) 33 | File.mtime(filename) < Time.now - 24 * 60 * 60 34 | end 35 | 36 | def read_from_wiki(name, filename) 37 | require 'open-uri' 38 | download = open('https://github.com/jruby/jruby/wiki/C-Extension-Alternatives.md') 39 | content = download.read(nil) 40 | File.open(filename, "w") { |f| f << content } 41 | content 42 | rescue => e 43 | raise "Error while reading from wiki: #{e.message}\nPlease try again later." 44 | end 45 | end 46 | 47 | class CExtensions 48 | attr_reader :gems 49 | 50 | def initialize(cache) 51 | @cache = cache 52 | end 53 | 54 | def load 55 | @gems = {} 56 | content = @cache.fetch('C-Extension-Alternatives.md') 57 | 58 | in_suggestions = false 59 | content.split("\n").each do |line| 60 | if line =~ / 53 | <% end %> 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /lib/jruby/lint/reporters/text.rb: -------------------------------------------------------------------------------- 1 | module JRuby::Lint 2 | module Reporters 3 | class Text 4 | def initialize(project, output, options=OpenStruct.new) 5 | @tags, @output, @options = project.tags, output, options 6 | end 7 | 8 | def report(findings) 9 | findings.each do |finding| 10 | puts finding unless (@tags & finding.tags).empty? 11 | end 12 | end 13 | 14 | def puts(finding) 15 | @output.puts finding.to_s 16 | end 17 | end 18 | 19 | class ANSIColor < Text 20 | require 'term/ansicolor' 21 | include Term::ANSIColor 22 | def puts(finding) 23 | msg = if finding.error? 24 | red(finding.to_s) 25 | elsif finding.warning? 26 | cyan(finding.to_s) 27 | else 28 | blue(finding.to_s) 29 | end 30 | @output.puts msg 31 | @output.puts finding.src_line if finding.src_line && !@options.no_src_line 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /lib/jruby/lint/version.rb: -------------------------------------------------------------------------------- 1 | module JRuby 2 | module Lint 3 | VERSION = "0.9.0" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /spec/fixtures/C-Extension-Alternatives.md: -------------------------------------------------------------------------------- 1 | JRuby does not support native C extensions, but it does have it's own Java native extensions API. Several gems have implementations of both Java and C extensions rolled into the same gem and those will not be listed here since they will just work. In some cases there is a JRuby version with a slightly different name or possibly even a totally different name and we list these here so you can update your Gemfile: 2 | 3 | ```ruby 4 | gem 'therubyracer', platform: :mri 5 | gem 'therubyrhino', platform: :jruby 6 | ``` 7 | 8 | When there is not an exact match some gems come close enough where a little work on your part can make your application compatible with JRuby. 9 | 10 | This page lists common C extensions and JRuby-friendly alternatives you can use to replace them. 11 | 12 | If you are interested in helping us port an extension to JRuby, this article is helpful: [Your first Ruby native extension: Java](https://blog.jcoglan.com/2012/08/02/your-first-ruby-native-extension-java/) see also [JRuby examples](https://github.com/jruby/jruby-examples) for a maven build. 13 | 14 | 15 | | Gem | Suggestions | 16 | |-----|-------------| 17 | |[RDiscount][]|Use [kramdown][], [Maruku][] (pure Ruby) or [markdown_j][] (wrapper around a Java library)| 18 | |[RedCarpet][]|Same as with **RDiscount** use alternatives such as [kramdown][], [Maruku][] or [markdown_j][]| 19 | |[RMagick][]|Try [RMagick4J][] (implements ImageMagick functionality in Java) or preferably use alternatives [mini_magick][] & [quick_magick][]. For simple resizing, cropping, greyscaling, etc look at [image_voodoo][]. You can also use Java's Graphics2D.| 20 | |[Unicorn][]| Use [Puma][].| 21 | |[Thin][]| Use [Puma][].| 22 | |mysql|Use [activerecord-jdbcmysql-adapter][].| 23 | |mysql2|Use [activerecord-jdbcmysql-adapter][].| 24 | |sqlite3|Use [activerecord-jdbcsqlite3-adapter][].| 25 | |pg|Use [activerecord-jdbcpostgresql-adapter][] instead or [pg_jruby][] (drop-in replacement).| 26 | |[yajl-ruby][]|Try `json` or `json_pure` instead. Unfortunately there is no known equivalent JSON stream parser.| 27 | |[oj][]|Try `gson`, `json` or `json_pure` instead.| 28 | |[bson_ext][]|`bson_ext` isn't used with JRuby. Instead, some native Java extensions are bundled with the `bson` gem.| 29 | |[win32ole][]|Use the `jruby-win32ole` gem (preinstalled in JRuby's Windows installer).| 30 | |[curb][]|[Rurl][] is an example how to implement _some_ of curb's functionality using [Apache HttpClient][]| 31 | |[therubyracer][]|Try using [therubyrhino][] instead (or [dienashorner][] on Java 8+).| 32 | |[kyotocabinet][]|Try using [kyotocabinet-java][] instead. This isn't 100% complete yet, but it covers most of the API.| 33 | |[memcached][]|Try using [jruby-memcached][] instead. Alternatively you can use [jruby-ehcache][], a JRuby interface to Java's (JSR-107 compliant) Ehcache.| 34 | |[charlock_holmes][]|Use [charlock_holmes-jruby][] instead.| 35 | 36 | 37 | Please add to this list with your findings. 38 | 39 | *Note that the [JRuby-Lint][] gem parses the contents of the list above to use for its Ruby gem checker. In order for JRuby-Lint to use the information, please adhere to the table format above and the links to projects below (in the source for this page). 40 | 41 | 42 | [RDiscount]: http://dafoster.net/projects/rdiscount/ 43 | [RedCarpet]: https://github.com/vmg/redcarpet 44 | [kramdown]: https://github.com/gettalong/kramdown 45 | [Maruku]:https://github.com/bhollis/maruku 46 | [markdown_j]: https://github.com/nate/markdown_j 47 | [RMagick]: https://github.com/rmagick/rmagick 48 | [RMagick4J]: https://github.com/Serabe/RMagick4J 49 | [mini_magick]: https://github.com/minimagick/minimagick 50 | [quick_magick]: https://github.com/aseldawy/quick_magick 51 | [image_voodoo]: https://github.com/jruby/image_voodoo 52 | [Unicorn]: http://unicorn.bogomips.org/ 53 | [Puma]: http://puma.io/ 54 | [Thin]: http://code.macournoyer.com/thin/ 55 | [Typhoeus]: https://github.com/dbalatero/typhoeus 56 | [activerecord-jdbc-adapter]: https://github.com/jruby/activerecord-jdbc-adapter 57 | [JRuby-Lint]: https://github.com/jruby/jruby-lint 58 | [Nokogiri]: http://nokogiri.org/ 59 | [yajl-ruby]: https://github.com/brianmario/yajl-ruby 60 | [bson_ext]: https://github.com/mongodb/mongo-ruby-driver 61 | [Apache HttpClient]: http://hc.apache.org/httpcomponents-client-ga/ 62 | [HttpURLConnection]: http://download.oracle.com/javase/1,5.0/docs/api/java/net/HttpURLConnection.html 63 | [win32ole]: http://www.ruby-doc.org/stdlib/libdoc/win32ole/rdoc/index.html 64 | [Rurl]: https://github.com/rcyrus/Rurl 65 | [curb]: https://github.com/taf2/curb 66 | [therubyracer]: https://github.com/cowboyd/therubyracer 67 | [therubyrhino]: https://github.com/cowboyd/therubyrhino 68 | [dienashorner]: https://github.com/kares/dienashorner 69 | [kyotocabinet]: http://fallabs.com/kyotocabinet/ 70 | [kyotocabinet-java]: https://github.com/csw/kyotocabinet-java 71 | [memcached]: https://github.com/evan/memcached 72 | [jruby-memcached]: https://github.com/aurorafeint/jruby-memcached 73 | [jruby-ehcache]: https://github.com/dylanz/ehcache 74 | [oj]: https://github.com/ohler55/oj 75 | [activerecord-jdbcmysql-adapter]: https://rubygems.org/gems/activerecord-jdbcmysql-adapter 76 | [activerecord-jdbcsqlite3-adapter]: https://rubygems.org/gems/activerecord-jdbcsqlite3-adapter 77 | [activerecord-jdbcpostgresql-adapter]: https://rubygems.org/gems/activerecord-jdbcpostgresql-adapter 78 | [pg_jruby]: https://rubygems.org/gems/pg_jruby 79 | [charlock_holmes]: https://github.com/brianmario/charlock_holmes 80 | [charlock_holmes-jruby]: https://github.com/siuying/charlock_holmes-jruby 81 | -------------------------------------------------------------------------------- /spec/jruby/lint/ast_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe JRuby::Lint::AST::Visitor do 4 | Given(:ast) { JRuby.parse(script) } 5 | Given(:visitor) { JRuby::Lint::AST::Visitor.new(ast) } 6 | 7 | # RootNode 8 | # FCallOneArgNode |puts| 9 | # ArrayNode 10 | # StrNode =="hello" 11 | Given(:script) { %{puts "hello"} } 12 | 13 | context "visits all nodes" do 14 | When { visitor.each_node { @count ||= 0; @count += 1} } 15 | Then { expect(@count).to eq(4) } 16 | end 17 | 18 | context "selects nodes" do 19 | When { @nodes = visitor.select {|n| n.node_type == org.jruby.ast.NodeType::STRNODE } } 20 | Then { expect(@nodes.size).to(eq(1)) && 21 | expect(@nodes.first.value.to_s).to(eq("hello")) } 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /spec/jruby/lint/checkers_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe JRuby::Lint::Checker do 4 | context "checkers" do 5 | subject { Class.new { include JRuby::Lint::Checker } } 6 | 7 | it "finds all loaded checkers" do 8 | expect(JRuby::Lint::Checker.loaded_checkers).to include(subject) 9 | end 10 | end 11 | end 12 | 13 | describe JRuby::Lint::Checkers do 14 | Given(:gems) { { "rdiscount" => "may not work", "bson_ext" => "not needed" } } 15 | Given(:project) {JRuby::Lint::Project.new.tap {|p| p.libraries.gems = gems }} 16 | Given(:collector) do 17 | JRuby::Lint::Collector.new(project).tap do |c| 18 | c.contents = script 19 | c.checkers = [checker] 20 | checker.collector = c 21 | end 22 | end 23 | 24 | context "Fork/exec checker" do 25 | Given(:checker) { JRuby::Lint::Checkers::ForkExec.new } 26 | 27 | context "detects fcall-style" do 28 | # FCallNoArgBlockNode |fork| 29 | Given(:script) { "fork { }" } 30 | When { collector.run } 31 | Then { expect(collector.findings.size).to eq(1) } 32 | end 33 | 34 | context "detects vcall-style" do 35 | # VCallNode |fork| 36 | Given(:script) { "fork" } 37 | When { collector.run } 38 | Then { expect(collector.findings.size).to eq(1) } 39 | end 40 | 41 | context "does not detect call-style" do 42 | # CallNoArgNode |fork| 43 | # VCallNode |fork| 44 | Given(:script) { "fork.fork" } 45 | When { collector.run } 46 | Then { expect(collector.findings.size).to eq(0) } 47 | end 48 | 49 | context "detects Kernel::fork style" do 50 | # CallNoArgNode |fork| 51 | # ConstNode |Kernel| 52 | Given(:script) { "Kernel::fork" } 53 | When { collector.run } 54 | Then { expect(collector.findings.size).to eq(1) } 55 | end 56 | end 57 | 58 | context "Gem checker" do 59 | Given(:checker) { JRuby::Lint::Checkers::Gem.new } 60 | 61 | context "creates a finding for a gem mentioned in the libraries" do 62 | Given(:script) { "gem 'rdiscount'" } 63 | When { collector.run } 64 | Then { expect(collector.findings.size).to eq(2) } 65 | end 66 | 67 | context "creates one finding to mention the wiki for gem compatibility" do 68 | Given(:script) { "gem 'rdiscount'; gem 'bson_ext'" } 69 | When { collector.run } 70 | Then { expect(collector.findings.size).to eq(3) } 71 | end 72 | 73 | context "ignores platform for gem compatibility if not right platform" do 74 | Given(:script) { "gem 'rdiscount', platform: :ruby" } 75 | When { collector.run } 76 | Then { expect(collector.findings.size).to eq(0) } 77 | end 78 | 79 | context "creates a finding if platform for gem compatibility is ours" do 80 | Given(:script) { "gem 'rdiscount', platform: :jruby" } 81 | When { collector.run } 82 | Then { expect(collector.findings.size).to eq(2) } 83 | end 84 | 85 | context "creates no finding if in wrong platform block" do 86 | Given(:script) { "platforms :ruby { gem 'rdiscount' }" } 87 | When { collector.run } 88 | Then { expect(collector.findings.size).to eq(1) } 89 | end 90 | 91 | context "does not create a finding for a gem not mentioned in the gems info" do 92 | Given(:script) { "gem 'json_pure'" } 93 | When { collector.run } 94 | Then { expect(collector.findings.size).to eq(0) } 95 | end 96 | 97 | context "only checks calls to #gem" do 98 | Given(:script) { "require 'rdiscount'" } 99 | When { collector.run } 100 | Then { expect(collector.findings.size).to eq(0) } 101 | end 102 | end 103 | 104 | context "Gemspec checker" do 105 | Given(:checker) { JRuby::Lint::Checkers::Gemspec.new } 106 | 107 | Given(:script) { "Gem::Specification.new do |s|" + 108 | "\ns.name = 'hello'\ns.add_dependency 'rdiscount'\n" + 109 | "s.add_development_dependency 'ruby-debug19'\nend\n" } 110 | 111 | When { collector.run } 112 | Then { expect(collector.findings.size).to eq(2) } 113 | Then { expect(collector.findings.detect{|f| f.message =~ /rdiscount/ }).to be_truthy } 114 | end 115 | 116 | context "Thread.critical checker" do 117 | Given(:checker) { JRuby::Lint::Checkers::ThreadCritical.new } 118 | 119 | context "read" do 120 | Given(:script) { "begin \n Thread.critical \n end"} 121 | When { collector.run } 122 | Then { expect(collector.findings.size).to eq(1) } 123 | end 124 | 125 | context "assign" do 126 | Given(:script) { "begin \n Thread.critical = true \n ensure Thread.critical = false \n end"} 127 | When { collector.run } 128 | Then { expect(collector.findings.size).to eq(2) } 129 | end 130 | end 131 | 132 | context "ObjectSpace" do 133 | Given(:checker) { JRuby::Lint::Checkers::ObjectSpace.new } 134 | 135 | context "_id2ref usage" do 136 | Given(:script) { "ObjectSpace._id2ref(obj)"} 137 | When { collector.run } 138 | Then { expect(collector.findings.size).to eq(1) } 139 | end 140 | 141 | context "each_object usage" do 142 | Given(:script) { "ObjectSpace.each_object { }"} 143 | When { collector.run } 144 | Then { expect(collector.findings.size).to eq(1) } 145 | end 146 | 147 | context "each_object(Class) usage is ok" do 148 | Given(:script) { "ObjectSpace.each_object(Class) { }"} 149 | When { collector.run } 150 | Then { collector.findings; expect(collector.findings.size).to eq(0) } 151 | end 152 | end 153 | 154 | context "System" do 155 | Given(:checker) { JRuby::Lint::Checkers::System.new } 156 | 157 | context "calling ruby -v in system" do 158 | Given(:script) { "system('echo'); system('/usr/bin/ruby -v')"} 159 | When { collector.run } 160 | Then { expect(collector.findings.size).to eq(1) } 161 | end 162 | 163 | context "calling ruby in the first argument to system" do 164 | Given(:script) { "system('/usr/bin/ruby', '-v')"} 165 | When { collector.run } 166 | Then { expect(collector.findings.size).to eq(1) } 167 | end 168 | 169 | context "calling irb or jirb from system" do 170 | Given(:script) { "system('jirb'); system('irb')"} 171 | When { collector.run } 172 | Then { expect(collector.findings.size).to eq(2) } 173 | end 174 | 175 | context "calling a .rb file from system" do 176 | Given(:script) { "system('asdf.rb')" } 177 | When { collector.run } 178 | Then { expect(collector.findings.size).to eq(1) } 179 | end 180 | 181 | context "calling ruby -v in Kernel.system should have a finding" do 182 | Given(:script) { "Kernel.system('ruby -v'); Kernel.system('echo \"zomg\"')"} 183 | When { collector.run } 184 | Then { expect(collector.findings.size).to eq(1) } 185 | end 186 | 187 | end 188 | 189 | context "Non-atomic operator assignment" do 190 | Given(:checker) { JRuby::Lint::Checkers::NonAtomic.new } 191 | 192 | context "class variable or-assignment" do 193 | Given(:script) { "@@foo ||= 1" } 194 | When { collector.run } 195 | Then { expect(collector.findings.size).to eq(1) } 196 | end 197 | 198 | context "instance variable or-assignment" do 199 | Given(:script) { "@foo ||= 1" } 200 | When { collector.run } 201 | Then { expect(collector.findings.size).to eq(1) } 202 | Then { expect(collector.findings.first.message).to be =~ /\(@foo\)/ } 203 | end 204 | 205 | context "attribute or-assignment" do 206 | Given(:script) { "foo.bar ||= 1" } 207 | When { collector.run } 208 | Then { expect(collector.findings.size).to eq(1) } 209 | Then { expect(collector.findings.first.message).to be =~ /\(bar\)/ } 210 | end 211 | 212 | context "element or-assignment" do 213 | Given(:script) { "foo[bar] ||= 1" } 214 | When { collector.run } 215 | Then { expect(collector.findings.size).to eq(1) } 216 | Then { expect(collector.findings.first.message).to be =~ /\(foo\[bar\]\)/ } 217 | end 218 | 219 | context "class variable and-assignment" do 220 | Given(:script) { "@@foo &&= 1" } 221 | When { collector.run } 222 | Then { expect(collector.findings.size).to eq(1) } 223 | Then { expect(collector.findings.first.message).to be =~ /\(@@foo\)/ } 224 | end 225 | 226 | context "instance variable and-assignment" do 227 | Given(:script) { "@foo &&= 1" } 228 | When { collector.run } 229 | Then { expect(collector.findings.size).to eq(1) } 230 | Then { expect(collector.findings.first.message).to be =~ /\(@foo\)/ } 231 | end 232 | 233 | context "attribute and-assignment" do 234 | Given(:script) { "foo.bar &&= 1" } 235 | When { collector.run } 236 | Then { expect(collector.findings.size).to eq(1) } 237 | Then { expect(collector.findings.first.message).to be =~ /\(bar\)/ } 238 | end 239 | 240 | context "element and-assignment" do 241 | Given(:script) { "foo[bar] &&= 1" } 242 | When { collector.run } 243 | Then { expect(collector.findings.size).to eq(1) } 244 | Then { expect(collector.findings.first.message).to be =~ /\(foo\[bar\]\)/ } 245 | end 246 | 247 | context "element and-assignment (complicated name)" do 248 | Given(:script) { "foo[bar(2, heh)] &&= 1" } 249 | When { collector.run } 250 | Then { expect(collector.findings.size).to eq(1) } 251 | Then { expect(collector.findings.first.message).to be =~ /\(foo\[bar\(2, heh\)\]\)/ } 252 | end 253 | 254 | context "class variable op-assignment" do 255 | Given(:script) { "@@foo += 1" } 256 | When { collector.run } 257 | Then { expect(collector.findings.size).to eq(1) } 258 | Then { expect(collector.findings.first.message).to be =~ /\(@@foo\)/ } 259 | end 260 | 261 | context "instance variable op-assignment" do 262 | Given(:script) { "@foo += 1" } 263 | When { collector.run } 264 | Then { expect(collector.findings.size).to eq(1) } 265 | Then { expect(collector.findings.first.message).to be =~ /\(@foo\)/ } 266 | end 267 | 268 | context "attribute op-assignment" do 269 | Given(:script) { "foo.bar += 1" } 270 | When { collector.run } 271 | Then { expect(collector.findings.size).to eq(1) } 272 | Then { expect(collector.findings.first.message).to be =~ /\(bar\)/ } 273 | end 274 | 275 | context "element op-assignment" do 276 | Given(:script) { "foo[bar] += 1" } 277 | When { collector.run } 278 | Then { expect(collector.findings.size).to eq(1) } 279 | Then { expect(collector.findings.first.message).to be =~ /\(foo\[bar\]\)/ } 280 | end 281 | 282 | context "ignores simple inst assignment" do 283 | Given(:script) { "@foo = 1" } 284 | When { collector.run } 285 | Then { expect(collector.findings.size).to eq(0) } 286 | end 287 | 288 | context "ignores simple cvar assignment" do 289 | Given(:script) { "@@foo = 1" } 290 | When { collector.run } 291 | Then { expect(collector.findings.size).to eq(0) } 292 | end 293 | end 294 | end 295 | -------------------------------------------------------------------------------- /spec/jruby/lint/collectors_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe JRuby::Lint::Collector do 4 | Given(:collector) { JRuby::Lint::Collector.new } 5 | Given(:checker_class) { Class.new { include JRuby::Lint::Checker } } 6 | 7 | context "loads detected checkers" do 8 | When { checker_class } 9 | Then { expect(collector.checkers.detect {|c| checker_class === c }).to be_truthy } 10 | end 11 | 12 | context "invokes all checkers" do 13 | Given(:checker) do 14 | double("checker").tap do |checker| 15 | expect(checker).to receive(:visitTrueNode) 16 | collector.checkers = [checker] 17 | end 18 | end 19 | When { collector.contents = 'true' } 20 | Then { collector.run } 21 | end 22 | 23 | context "reports syntax errors as findings" do 24 | When { collector.contents = '<% true %>' } 25 | When { collector.run } 26 | Then { expect(collector.findings.size).to eq(1) } 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /spec/jruby/lint/finding_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe JRuby::Lint::Finding do 4 | Given(:message) { "bad code" } 5 | Given(:file) { "file" } 6 | Given(:line) { 19 } 7 | Given(:tags) { ["threads", "info"] } 8 | 9 | context "has a message, location and tags" do 10 | When { @finding = JRuby::Lint::Finding.new(message, tags, file, line) } 11 | Then { expect(@finding.message).to eq(message) } 12 | Then { expect(@finding.tags).to eq(tags) } 13 | Then { expect(@finding.file).to eq(file) } 14 | Then { expect(@finding.line).to eq(line) } 15 | Then { expect(@finding.to_s).to eq("#{file}:#{line}: [#{tags.join(', ')}] #{message}") } 16 | end 17 | 18 | context "can receive location from SourcePosition" do 19 | Given(:source_position) { org.jruby.lexer.yacc.SimpleSourcePosition.new(file, line) } 20 | 21 | When { @finding = JRuby::Lint::Finding.new(message, tags, source_position) } 22 | Then { expect(@finding.file).to eq(file) } 23 | Then { expect(@finding.line).to eq(line + 1) } 24 | end 25 | 26 | context "converts all tags to strings" do 27 | Given(:tags) { [1, :two, 3.0] } 28 | When { @finding = JRuby::Lint::Finding.new(message, tags, file, line) } 29 | Then { expect(@finding.tags).to eq(["1", "two", "3.0"]) } 30 | end 31 | 32 | context "with error tags" do 33 | Given(:tags) { [:error] } 34 | When { @finding = JRuby::Lint::Finding.new(message, tags, file, line) } 35 | Then { expect(@finding).to be_error } 36 | end 37 | 38 | context "with warnings tags" do 39 | Given(:tags) { [:warning] } 40 | When { @finding = JRuby::Lint::Finding.new(message, tags, file, line) } 41 | Then { expect(@finding).to be_warning } 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /spec/jruby/lint/libraries_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe JRuby::Lint::Libraries do 4 | Given(:cache_dir) { ENV['JRUBY_LINT_CACHE'] } 5 | Given(:cache) { JRuby::Lint::Libraries::Cache.new(cache_dir) } 6 | 7 | context "cache" do 8 | Given(:cache_dir) { expand_path(".") } 9 | 10 | context "with net access", :requires_net => true do 11 | context "fetch" do 12 | When { cache.fetch('C-Extension-Alternatives') } 13 | Then { expect('C-Extension-Alternatives.md').to be_an_existing_file } 14 | end 15 | 16 | context "refreshes a file that's too old" do 17 | Given { write_file('C-Extension-Alternatives.md', 'alternatives') } 18 | Given(:yesterday) { Time.now - 25 * 60 * 60 } 19 | Given { File.utime yesterday, yesterday, File.join(expand_path("."), 'C-Extension-Alternatives.md')} 20 | When { cache.fetch('C-Extension-Alternatives') } 21 | Then { expect(File.mtime(File.join(expand_path("."), 'C-Extension-Alternatives.md'))).to be > yesterday } 22 | end 23 | end 24 | 25 | context "with no net access" do 26 | Given { expect(Net::HTTP).not_to receive(:start) } 27 | 28 | context "store assumes .md extension by default" do 29 | When { cache.store('hello.yml', 'hi')} 30 | Then { expect('hello.yml').to be_an_existing_file } 31 | end 32 | 33 | context "store assumes .md extension by default" do 34 | When { cache.store('hello', 'hi')} 35 | Then { expect('hello.md').to be_an_existing_file } 36 | end 37 | 38 | context "fetch should not access net when file is cached" do 39 | Given { write_file('hello.md', 'hi') } 40 | When { cache.fetch('hello') } 41 | end 42 | end 43 | end 44 | 45 | context "c extensions list" do 46 | Given(:list) { JRuby::Lint::Libraries::CExtensions.new(cache) } 47 | When { list.load } 48 | Then { expect(list.gems.keys).to include("rdiscount", "rmagick")} 49 | end 50 | 51 | context "aggregate information" do 52 | Given(:info) { JRuby::Lint::Libraries.new(cache) } 53 | When { info.load } 54 | Then { expect(info.gems.keys).to include("rdiscount", "rmagick")} 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /spec/jruby/lint/project_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe JRuby::Lint::Project do 4 | Given(:project) { cd('.') { JRuby::Lint::Project.new.tap {|p| p.reporters.clear } } } 5 | 6 | context "collects Ruby scripts" do 7 | Given { write_file('script.rb', '') } 8 | When { @collectors = project.collectors } 9 | Then { expect(@collectors.size).to eq(1) } 10 | Then { expect(@collectors.first).to be_instance_of(JRuby::Lint::Collectors::Ruby) } 11 | end 12 | 13 | context "collects Bundler Gemfiles" do 14 | Given { write_file('Gemfile', '') } 15 | When { @collectors = project.collectors } 16 | Then { expect(@collectors.size).to eq(1) } 17 | Then { expect(@collectors.first).to be_instance_of(JRuby::Lint::Collectors::Bundler) } 18 | end 19 | 20 | context "collects Rakefiles" do 21 | Given { write_file('Rakefile', '') } 22 | When { @collectors = project.collectors } 23 | Then { expect(@collectors.size).to eq(1) } 24 | Then { expect(@collectors.first).to be_instance_of(JRuby::Lint::Collectors::Rake) } 25 | end 26 | 27 | context "collects gemspecs" do 28 | Given { write_file('temp.gemspec', '') } 29 | When { @collectors = project.collectors } 30 | Then { expect(@collectors.size).to eq(1) } 31 | Then { expect(@collectors.first).to be_instance_of(JRuby::Lint::Collectors::Gemspec) } 32 | end 33 | 34 | context "aggregates findings from all collectors" do 35 | Given(:collector1) do 36 | double("collector 1").tap do |c1| 37 | expect(c1).to receive(:run) 38 | allow(c1).to receive(:findings) { [double("finding 1")] } 39 | end 40 | end 41 | Given(:collector2) do 42 | double("collector 2").tap do |c2| 43 | expect(c2).to receive(:run) 44 | allow(c2).to receive(:findings) { [double("finding 2")] } 45 | end 46 | end 47 | 48 | When { project.collectors.replace([collector1, collector2]) } 49 | When { findings = project.run } 50 | 51 | Then { expect(project.findings.size).to eq(2) } 52 | end 53 | 54 | context "reports findings" do 55 | Given(:finding) { double "finding" } 56 | 57 | Given(:collector) do 58 | double("collector").tap do |c| 59 | expect(c).to receive(:run) 60 | allow(c).to receive(:findings) { [finding] } 61 | end 62 | end 63 | 64 | Given(:reporter) do 65 | double("reporter").tap do |r| 66 | expect(r).to receive(:report).with([finding]) 67 | end 68 | end 69 | 70 | When do 71 | allow(reporter).to receive(:print_report) 72 | expect(reporter).to receive(:print_report).with([finding]) 73 | end 74 | 75 | When do 76 | project.collectors.replace [collector] 77 | project.reporters.replace [reporter] 78 | end 79 | 80 | Then { project.run } 81 | end 82 | 83 | context 'initializing' do 84 | Given(:options) { OpenStruct.new } 85 | Given(:project) { cd('.') { JRuby::Lint::Project.new(options) } } 86 | When { allow(STDOUT).to receive(:tty?).and_return(false) } 87 | 88 | context 'tags' do 89 | Given(:options) { OpenStruct.new(:tags => ["debug"]) } 90 | Then { expect(project.tags).to include("debug") } 91 | Then { expect(project.tags).to include(*JRuby::Lint::Project::DEFAULT_TAGS) } 92 | end 93 | 94 | context 'reporters' do 95 | context 'with html option' do 96 | Given(:options) { OpenStruct.new(:html => 'report.html') } 97 | Then { expect(project.reporters.size).to equal(1) } 98 | Then { expect(project.reporters.first).to be_an_instance_of(JRuby::Lint::Reporters::Html) } 99 | end 100 | 101 | context 'with ansi option' do 102 | Given(:options) { OpenStruct.new(:ansi => true) } 103 | Then { expect(project.reporters.size).to equal(1) } 104 | Then { expect(project.reporters.first).to be_an_instance_of(JRuby::Lint::Reporters::ANSIColor) } 105 | end 106 | 107 | context 'with text option' do 108 | Given(:options) { OpenStruct.new(:text => true) } 109 | Then { expect(project.reporters.size).to equal(1) } 110 | Then { expect(project.reporters.first).to be_an_instance_of(JRuby::Lint::Reporters::Text) } 111 | end 112 | 113 | context 'without any option' do 114 | Then { expect(project.reporters.size).to equal(1) } 115 | Then { expect(project.reporters.first).to be_an_instance_of(JRuby::Lint::Reporters::Text) } 116 | end 117 | 118 | context 'with several options' do 119 | Given(:options) { OpenStruct.new(:ansi => true, :html => 'report.html') } 120 | Then { expect(project.reporters.size).to eq(2) } 121 | Then { expect(project.reporters.map(&:class)).to include(JRuby::Lint::Reporters::ANSIColor) } 122 | Then { expect(project.reporters.map(&:class)).to include(JRuby::Lint::Reporters::Html) } 123 | end 124 | end 125 | end 126 | end 127 | -------------------------------------------------------------------------------- /spec/jruby/lint/reporters_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe JRuby::Lint::Reporters do 4 | Given(:project) { double "project", :tags => %w(warning error info) } 5 | 6 | context "Text reporter" do 7 | Given(:reporter) { JRuby::Lint::Reporters::Text.new(project, output) } 8 | 9 | context "with a finding sharing a tag with the project" do 10 | Given(:finding) { double "finding", :to_s => "hello", :tags => %w(info) } 11 | Given(:output) { double("output").tap {|o| expect(o).to receive(:puts).with("hello") } } 12 | 13 | Then { reporter.report [finding] } 14 | end 15 | 16 | context "with a finding sharing no tags with the project" do 17 | Given(:finding) { double "finding", :to_s => "hello", :tags => %w(debug) } 18 | Given(:output) { double("output").tap {|o| expect(o).to_not receive(:puts) } } 19 | 20 | Then { reporter.report [finding] } 21 | end 22 | end 23 | 24 | context "Color text reporter" do 25 | include Term::ANSIColor 26 | Given(:reporter) { JRuby::Lint::Reporters::ANSIColor.new(project, output) } 27 | 28 | context "shows a finding tagged 'error' in red" do 29 | Given(:finding) { double "finding", src_line: "line", to_s: "hello", tags: %w(error), "error?": true } 30 | Given(:output) do 31 | double("output").tap do |o| 32 | expect(o).to receive(:puts).with(red("hello")) 33 | expect(o).to receive(:puts).with("line") 34 | end 35 | end 36 | 37 | Then { reporter.report [finding] } 38 | end 39 | 40 | context "shows a finding tagged 'warning' in cyan" do 41 | Given(:finding) { double "finding", :src_line => "line", :to_s => "hello", :tags => %w(warning), :error? => false, :warning? => true } 42 | Given(:output) do 43 | double("output").tap do |o| 44 | expect(o).to receive(:puts).with(cyan("hello")) 45 | expect(o).to receive(:puts).with("line") 46 | end 47 | end 48 | Then { reporter.report [finding] } 49 | end 50 | end 51 | 52 | context "Html reporter" do 53 | Given(:reporter) { JRuby::Lint::Reporters::Html.new(project, 'lint-spec-report.html') } 54 | 55 | context "shows a finding tagged 'error' in red" do 56 | Given(:finding) { double "finding", :src_line => "line", :to_s => "hello", :tags => %w(error), :error? => true } 57 | Then { reporter.print_report [finding] } 58 | Then { expect(File.read('lint-spec-report.html')).to include('
  • hello
  • ') } 59 | end 60 | 61 | context "shows a finding tagged 'warning' in yellow" do 62 | Given(:finding) { double "finding", :src_line => "line", :to_s => "hello", :tags => %w(warning), :error? => false, :warning? => true } 63 | Then { reporter.print_report [finding] } 64 | Then { expect(File.read('lint-spec-report.html')).to include('
  • hello
  • ') } 65 | end 66 | 67 | context "shows a nice message when we don't find any issue" do 68 | When { reporter.print_report [] } 69 | Then { expect(File.read('lint-spec-report.html')).to include('Congratulations!') } 70 | end 71 | end 72 | end 73 | -------------------------------------------------------------------------------- /spec/jruby/lint/version_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../../spec_helper', __FILE__) 2 | 3 | describe JRuby::Lint, "version" do 4 | Given(:version) { JRuby::Lint::VERSION } 5 | Then { expect(version).to be >= "0" } 6 | end 7 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'rspec' 2 | require 'rspec/given' 3 | require 'jruby/lint' 4 | require 'aruba/api' 5 | 6 | module JRuby::Lint::Specs 7 | PROJECT_DIR = File.expand_path('../..', __FILE__) 8 | def project_dir 9 | PROJECT_DIR 10 | end 11 | ENV['JRUBY_LINT_CACHE'] = "#{PROJECT_DIR}/spec/fixtures" 12 | end 13 | 14 | RSpec.configure do |config| 15 | config.include JRuby::Lint::Specs 16 | config.include Aruba::Api 17 | 18 | config.filter_run_excluding :requires_net => true unless ENV['RUN_ALL_SPECS'] 19 | 20 | config.before do 21 | @aruba_timeout_seconds = 20 22 | @existing_checkers = JRuby::Lint::Checker.loaded_checkers.dup 23 | cd('.') { Dir['**/*'].each {|f| File.unlink(f) if File.file?(f) } } 24 | JRuby::Lint::Checkers::CheckGemNode.instance_eval { @added_wiki_link = nil } 25 | end 26 | 27 | config.after do 28 | JRuby::Lint::Checker.loaded_checkers.replace(@existing_checkers) 29 | end 30 | end 31 | --------------------------------------------------------------------------------