exercism-analysis 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (579) hide show
  1. checksums.yaml +7 -0
  2. data/exercism-analysis.gemspec +30 -0
  3. data/lib/exercism-analysis.rb +38 -0
  4. data/lib/exercism-analysis/adapters/adapter.rb +23 -0
  5. data/lib/exercism-analysis/adapters/clojure.rb +13 -0
  6. data/lib/exercism-analysis/adapters/go.rb +19 -0
  7. data/lib/exercism-analysis/adapters/javascript.rb +13 -0
  8. data/lib/exercism-analysis/adapters/python.rb +13 -0
  9. data/lib/exercism-analysis/adapters/ruby.rb +19 -0
  10. data/lib/exercism-analysis/analysis.rb +18 -0
  11. data/lib/exercism-analysis/analyzers/analyzer.rb +54 -0
  12. data/lib/exercism-analysis/analyzers/clojure/kibit.rb +25 -0
  13. data/lib/exercism-analysis/analyzers/go/golint.rb +23 -0
  14. data/lib/exercism-analysis/analyzers/javascript/jslint.rb +24 -0
  15. data/lib/exercism-analysis/analyzers/python/pylint.rb +24 -0
  16. data/lib/exercism-analysis/analyzers/ruby/control_flow.rb +21 -0
  17. data/lib/exercism-analysis/analyzers/ruby/enumerable_condition.rb +21 -0
  18. data/lib/exercism-analysis/analyzers/ruby/for_loop.rb +29 -0
  19. data/lib/exercism-analysis/analyzers/ruby/indentation.rb +21 -0
  20. data/lib/exercism-analysis/analyzers/ruby/iter_mutation.rb +37 -0
  21. data/lib/exercism-analysis/analyzers/ruby/output.rb +20 -0
  22. data/lib/exercism-analysis/analyzers/ruby/range.rb +28 -0
  23. data/lib/exercism-analysis/analyzers/ruby/roodi.rb +19 -0
  24. data/lib/exercism-analysis/analyzers/ruby/send.rb +25 -0
  25. data/lib/exercism-analysis/analyzers/ruby/shebang.rb +23 -0
  26. data/lib/exercism-analysis/analyzers/ruby/tab.rb +38 -0
  27. data/lib/exercism-analysis/processors/call_processor.rb +39 -0
  28. data/lib/exercism-analysis/processors/control_flow_processor.rb +27 -0
  29. data/lib/exercism-analysis/processors/enumerable_condition_processor.rb +31 -0
  30. data/lib/exercism-analysis/processors/for_loop_processor.rb +21 -0
  31. data/lib/exercism-analysis/processors/indentation_processor.rb +69 -0
  32. data/lib/exercism-analysis/processors/iter_mutation_processor.rb +50 -0
  33. data/lib/exercism-analysis/processors/processor.rb +34 -0
  34. data/lib/exercism-analysis/processors/range_processor.rb +23 -0
  35. data/lib/exercism-analysis/processors/send_processor.rb +23 -0
  36. data/lib/exercism-analysis/templates/each_to_map.rb +29 -0
  37. data/lib/exercism-analysis/templates/each_to_select.rb +31 -0
  38. data/lib/exercism-analysis/templates/range_exclusive.rb +19 -0
  39. data/lib/exercism-analysis/templates/template.rb +29 -0
  40. data/vendor/clojure/kibit-runner/LICENSE +214 -0
  41. data/vendor/clojure/kibit-runner/project.clj +10 -0
  42. data/vendor/clojure/kibit-runner/src/kibit_runner/core.clj +17 -0
  43. data/vendor/clojure/kibit-runner/target/kibit-runner-0.1.0-SNAPSHOT-standalone.jar +0 -0
  44. data/vendor/clojure/kibit-runner/target/kibit-runner-0.1.0-SNAPSHOT.jar +0 -0
  45. data/vendor/clojure/kibit-runner/target/stale/extract-native.dependencies +1 -0
  46. data/vendor/go/src/github.com/golang/lint/LICENSE +27 -0
  47. data/vendor/go/src/github.com/golang/lint/README +59 -0
  48. data/vendor/go/src/github.com/golang/lint/golint/golint.go +67 -0
  49. data/vendor/go/src/github.com/golang/lint/lint.go +1061 -0
  50. data/vendor/go/src/runner/golint_runner.go +23 -0
  51. data/vendor/javascript/jshint_runner.js +6 -0
  52. data/vendor/javascript/node_modules/jshint/README.md +47 -0
  53. data/vendor/javascript/node_modules/jshint/bin/apply +6 -0
  54. data/vendor/javascript/node_modules/jshint/bin/build +36 -0
  55. data/vendor/javascript/node_modules/jshint/bin/changelog +36 -0
  56. data/vendor/javascript/node_modules/jshint/bin/jshint +3 -0
  57. data/vendor/javascript/node_modules/jshint/bin/land +34 -0
  58. data/vendor/javascript/node_modules/jshint/data/ascii-identifier-data.js +22 -0
  59. data/vendor/javascript/node_modules/jshint/data/non-ascii-identifier-part-only.js +1570 -0
  60. data/vendor/javascript/node_modules/jshint/data/non-ascii-identifier-start.js +48477 -0
  61. data/vendor/javascript/node_modules/jshint/dist/jshint-rhino.js +60642 -0
  62. data/vendor/javascript/node_modules/jshint/dist/jshint.js +60525 -0
  63. data/vendor/javascript/node_modules/jshint/node_modules/cli/README.md +196 -0
  64. data/vendor/javascript/node_modules/jshint/node_modules/cli/cli.js +1139 -0
  65. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/cat.js +17 -0
  66. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/command.js +16 -0
  67. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/echo.js +54 -0
  68. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/glob.js +6 -0
  69. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/long_desc.js +20 -0
  70. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/progress.js +11 -0
  71. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/sort.js +18 -0
  72. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/spinner.js +9 -0
  73. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/static.coffee +27 -0
  74. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/static.js +25 -0
  75. data/vendor/javascript/node_modules/jshint/node_modules/cli/index.js +1 -0
  76. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/LICENSE +27 -0
  77. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/README.md +250 -0
  78. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/examples/g.js +9 -0
  79. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/examples/usr-local.js +9 -0
  80. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/glob.js +728 -0
  81. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/LICENSE +16 -0
  82. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/README.md +42 -0
  83. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/inherits.js +1 -0
  84. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
  85. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/package.json +51 -0
  86. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/test.js +25 -0
  87. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/package.json +58 -0
  88. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/00-setup.js +176 -0
  89. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/bash-comparison.js +63 -0
  90. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/bash-results.json +351 -0
  91. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/cwd-test.js +55 -0
  92. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/globstar-match.js +19 -0
  93. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/mark.js +118 -0
  94. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/new-glob-optional-options.js +10 -0
  95. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/nocase-nomagic.js +113 -0
  96. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/pause-resume.js +73 -0
  97. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/readme-issue.js +36 -0
  98. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/root-nomount.js +39 -0
  99. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/root.js +46 -0
  100. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/stat.js +32 -0
  101. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/zz-cleanup.js +11 -0
  102. data/vendor/javascript/node_modules/jshint/node_modules/cli/package.json +70 -0
  103. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/LICENCE +19 -0
  104. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/README.md +33 -0
  105. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/index.js +86 -0
  106. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/LICENCE +19 -0
  107. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/README.md +45 -0
  108. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/index.js +5 -0
  109. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/package.json +89 -0
  110. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/seed.js +16 -0
  111. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/test/index.js +28 -0
  112. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/test/static/index.html +10 -0
  113. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/package.json +88 -0
  114. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/test/index.js +67 -0
  115. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/test/static/index.html +12 -0
  116. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/test/static/test-adapter.js +53 -0
  117. data/vendor/javascript/node_modules/jshint/node_modules/exit/Gruntfile.js +48 -0
  118. data/vendor/javascript/node_modules/jshint/node_modules/exit/LICENSE-MIT +22 -0
  119. data/vendor/javascript/node_modules/jshint/node_modules/exit/README.md +75 -0
  120. data/vendor/javascript/node_modules/jshint/node_modules/exit/lib/exit.js +41 -0
  121. data/vendor/javascript/node_modules/jshint/node_modules/exit/package.json +69 -0
  122. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/exit_test.js +121 -0
  123. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/10-stderr.txt +10 -0
  124. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/10-stdout-stderr.txt +20 -0
  125. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/10-stdout.txt +10 -0
  126. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/100-stderr.txt +100 -0
  127. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/100-stdout-stderr.txt +200 -0
  128. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/100-stdout.txt +100 -0
  129. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/1000-stderr.txt +1000 -0
  130. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/1000-stdout-stderr.txt +2000 -0
  131. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/1000-stdout.txt +1000 -0
  132. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/create-files.sh +8 -0
  133. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/log-broken.js +23 -0
  134. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/log.js +25 -0
  135. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/LICENSE +18 -0
  136. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/README.md +83 -0
  137. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/CollectingHandler.js +55 -0
  138. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/FeedHandler.js +95 -0
  139. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/Parser.js +337 -0
  140. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/ProxyHandler.js +27 -0
  141. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/Stream.js +35 -0
  142. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/Tokenizer.js +891 -0
  143. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/WritableStream.js +21 -0
  144. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/index.js +68 -0
  145. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/LICENSE +11 -0
  146. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/index.js +14 -0
  147. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/package.json +40 -0
  148. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/readme.md +1 -0
  149. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/LICENSE +11 -0
  150. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/index.js +211 -0
  151. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/package.json +68 -0
  152. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/readme.md +102 -0
  153. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/01-basic.json +57 -0
  154. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/02-single_tag_1.json +21 -0
  155. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/03-single_tag_2.json +21 -0
  156. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/04-unescaped_in_script.json +27 -0
  157. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/05-tags_in_comment.json +18 -0
  158. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/06-comment_in_script.json +18 -0
  159. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/07-unescaped_in_style.json +20 -0
  160. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/08-extra_spaces_in_tag.json +20 -0
  161. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/09-unquoted_attrib.json +20 -0
  162. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/10-singular_attribute.json +15 -0
  163. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/11-text_outside_tags.json +40 -0
  164. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/12-text_only.json +11 -0
  165. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/13-comment_in_text.json +19 -0
  166. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/14-comment_in_text_in_script.json +18 -0
  167. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/15-non-verbose.json +22 -0
  168. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/16-normalize_whitespace.json +47 -0
  169. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/17-xml_namespace.json +18 -0
  170. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/18-enforce_empty_tags.json +16 -0
  171. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/19-ignore_empty_tags.json +20 -0
  172. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/20-template_script_tags.json +20 -0
  173. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/21-conditional_comments.json +15 -0
  174. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/22-lowercase_tags.json +41 -0
  175. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/23-dom-lvl1.json +121 -0
  176. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/tests.js +58 -0
  177. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/LICENSE +11 -0
  178. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/index.js +14 -0
  179. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/helpers.js +141 -0
  180. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/legacy.js +87 -0
  181. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/manipulation.js +77 -0
  182. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/querying.js +94 -0
  183. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/stringify.js +93 -0
  184. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/traversal.js +24 -0
  185. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/package.json +71 -0
  186. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/readme.md +1 -0
  187. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/fixture.js +6 -0
  188. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/tests/helpers.js +89 -0
  189. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/tests/legacy.js +119 -0
  190. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/utils.js +9 -0
  191. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/LICENSE +11 -0
  192. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/index.js +31 -0
  193. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/lib/decode.js +72 -0
  194. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/lib/decode_codepoint.js +26 -0
  195. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/lib/encode.js +48 -0
  196. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/decode.json +1 -0
  197. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/entities.json +1 -0
  198. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/legacy.json +1 -0
  199. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/xml.json +1 -0
  200. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/package.json +79 -0
  201. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/readme.md +31 -0
  202. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/test/mocha.opts +2 -0
  203. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/test/test.js +150 -0
  204. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/LICENSE +18 -0
  205. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/README.md +15 -0
  206. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/duplex.js +1 -0
  207. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/float.patch +923 -0
  208. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_duplex.js +89 -0
  209. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_passthrough.js +46 -0
  210. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_readable.js +944 -0
  211. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_transform.js +209 -0
  212. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_writable.js +472 -0
  213. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/README.md +3 -0
  214. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/float.patch +604 -0
  215. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/lib/util.js +107 -0
  216. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/package.json +53 -0
  217. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/util.js +106 -0
  218. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/LICENSE +16 -0
  219. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/README.md +42 -0
  220. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/inherits.js +1 -0
  221. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/inherits_browser.js +23 -0
  222. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/package.json +51 -0
  223. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/test.js +25 -0
  224. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/README.md +54 -0
  225. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/build/build.js +209 -0
  226. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/component.json +19 -0
  227. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/index.js +3 -0
  228. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/package.json +54 -0
  229. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/LICENSE +20 -0
  230. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/README.md +7 -0
  231. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/index.js +200 -0
  232. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/package.json +53 -0
  233. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/package.json +68 -0
  234. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/passthrough.js +1 -0
  235. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/readable.js +7 -0
  236. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/transform.js +1 -0
  237. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/writable.js +1 -0
  238. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/package.json +90 -0
  239. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/01-events.js +9 -0
  240. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/02-stream.js +23 -0
  241. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/03-feed.js +19 -0
  242. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/Atom_Example.xml +25 -0
  243. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/Attributes.html +16 -0
  244. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/Basic.html +1 -0
  245. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/RDF_Example.xml +63 -0
  246. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/RSS_Example.xml +48 -0
  247. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/01-simple.json +44 -0
  248. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/02-template.json +63 -0
  249. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/03-lowercase_tags.json +46 -0
  250. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/04-cdata.json +50 -0
  251. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/05-cdata-special.json +35 -0
  252. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/06-leading-lt.json +16 -0
  253. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/07-self-closing.json +67 -0
  254. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/08-implicit-close-tags.json +59 -0
  255. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/09-attributes.json +68 -0
  256. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/10-crazy-attrib.json +52 -0
  257. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/11-script_in_script.json +54 -0
  258. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/12-long-comment-end.json +20 -0
  259. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/13-long-cdata-end.json +22 -0
  260. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/14-implicit-open-tags.json +27 -0
  261. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/15-lt-whitespace.json +16 -0
  262. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/16-double_attribs.json +45 -0
  263. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/17-numeric_entities.json +16 -0
  264. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/18-legacy_entities.json +16 -0
  265. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/19-named_entities.json +16 -0
  266. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/20-xml_entities.json +16 -0
  267. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/21-entity_in_attribute.json +38 -0
  268. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/22-double_brackets.json +41 -0
  269. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/23-legacy_entity_fail.json +16 -0
  270. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/24-special_special.json +133 -0
  271. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/25-empty_tag_name.json +13 -0
  272. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/26-not-quite-closed.json +35 -0
  273. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/27-entities_in_attributes.json +62 -0
  274. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/28-cdata_in_html.json +9 -0
  275. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/29-comment_edge-cases.json +18 -0
  276. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/30-cdata_edge-cases.json +22 -0
  277. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Feeds/01-rss.js +34 -0
  278. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Feeds/02-atom.js +18 -0
  279. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Feeds/03-rdf.js +20 -0
  280. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/01-basic.json +83 -0
  281. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/02-RSS.json +1093 -0
  282. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/03-Atom.json +644 -0
  283. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/04-RDF.json +1399 -0
  284. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/05-Attributes.json +354 -0
  285. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/api.js +63 -0
  286. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/test-helper.js +83 -0
  287. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/LICENSE +23 -0
  288. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/README.md +218 -0
  289. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/minimatch.js +1061 -0
  290. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS +14 -0
  291. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/LICENSE +23 -0
  292. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/README.md +97 -0
  293. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +252 -0
  294. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/package.json +50 -0
  295. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/test/basic.js +369 -0
  296. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/test/foreach.js +52 -0
  297. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js +50 -0
  298. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/LICENSE +27 -0
  299. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/README.md +53 -0
  300. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/bench.js +283 -0
  301. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/package.json +58 -0
  302. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/sigmund.js +39 -0
  303. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/test/basic.js +24 -0
  304. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/package.json +57 -0
  305. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/basic.js +399 -0
  306. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/brace-expand.js +33 -0
  307. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/caching.js +14 -0
  308. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/defaults.js +274 -0
  309. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
  310. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/LICENSE +26 -0
  311. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/README.md +569 -0
  312. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/bin/shjs +51 -0
  313. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/global.js +3 -0
  314. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/make.js +47 -0
  315. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/package.json +61 -0
  316. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/scripts/generate-docs.js +21 -0
  317. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/scripts/run-tests.js +50 -0
  318. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/shell.js +157 -0
  319. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/cat.js +43 -0
  320. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/cd.js +19 -0
  321. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/chmod.js +208 -0
  322. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/common.js +203 -0
  323. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/cp.js +201 -0
  324. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/dirs.js +191 -0
  325. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/echo.js +20 -0
  326. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/error.js +10 -0
  327. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/exec.js +181 -0
  328. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/find.js +51 -0
  329. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/grep.js +52 -0
  330. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/ln.js +53 -0
  331. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/ls.js +126 -0
  332. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/mkdir.js +68 -0
  333. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/mv.js +80 -0
  334. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/popd.js +1 -0
  335. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/pushd.js +1 -0
  336. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/pwd.js +11 -0
  337. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/rm.js +145 -0
  338. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/sed.js +43 -0
  339. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/tempdir.js +56 -0
  340. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/test.js +85 -0
  341. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/to.js +29 -0
  342. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/toEnd.js +29 -0
  343. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/which.js +83 -0
  344. data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/cli.js +41 -0
  345. data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/package.json +76 -0
  346. data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/readme.md +74 -0
  347. data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/strip-json-comments.js +64 -0
  348. data/vendor/javascript/node_modules/jshint/node_modules/underscore/LICENSE +23 -0
  349. data/vendor/javascript/node_modules/jshint/node_modules/underscore/README.md +22 -0
  350. data/vendor/javascript/node_modules/jshint/node_modules/underscore/package.json +66 -0
  351. data/vendor/javascript/node_modules/jshint/node_modules/underscore/underscore-min.js +6 -0
  352. data/vendor/javascript/node_modules/jshint/node_modules/underscore/underscore.js +1343 -0
  353. data/vendor/javascript/node_modules/jshint/package.json +80 -0
  354. data/vendor/javascript/node_modules/jshint/src/cli.js +731 -0
  355. data/vendor/javascript/node_modules/jshint/src/jshint.js +5023 -0
  356. data/vendor/javascript/node_modules/jshint/src/lex.js +1650 -0
  357. data/vendor/javascript/node_modules/jshint/src/messages.js +223 -0
  358. data/vendor/javascript/node_modules/jshint/src/platforms/rhino.js +115 -0
  359. data/vendor/javascript/node_modules/jshint/src/reg.js +38 -0
  360. data/vendor/javascript/node_modules/jshint/src/reporters/checkstyle.js +81 -0
  361. data/vendor/javascript/node_modules/jshint/src/reporters/default.js +34 -0
  362. data/vendor/javascript/node_modules/jshint/src/reporters/jslint_xml.js +57 -0
  363. data/vendor/javascript/node_modules/jshint/src/reporters/non_error.js +52 -0
  364. data/vendor/javascript/node_modules/jshint/src/state.js +28 -0
  365. data/vendor/javascript/node_modules/jshint/src/style.js +143 -0
  366. data/vendor/javascript/node_modules/jshint/src/vars.js +658 -0
  367. data/vendor/python/astroid/COPYING +339 -0
  368. data/vendor/python/astroid/COPYING.LESSER +510 -0
  369. data/vendor/python/astroid/ChangeLog +574 -0
  370. data/vendor/python/astroid/MANIFEST.in +9 -0
  371. data/vendor/python/astroid/README +56 -0
  372. data/vendor/python/astroid/README.Python3 +26 -0
  373. data/vendor/python/astroid/__init__.py +118 -0
  374. data/vendor/python/astroid/__init__.pyc +0 -0
  375. data/vendor/python/astroid/__pkginfo__.py +48 -0
  376. data/vendor/python/astroid/__pkginfo__.pyc +0 -0
  377. data/vendor/python/astroid/announce.txt +23 -0
  378. data/vendor/python/astroid/as_string.py +496 -0
  379. data/vendor/python/astroid/as_string.pyc +0 -0
  380. data/vendor/python/astroid/bases.py +618 -0
  381. data/vendor/python/astroid/bases.pyc +0 -0
  382. data/vendor/python/astroid/brain/py2gi.py +159 -0
  383. data/vendor/python/astroid/brain/py2gi.pyc +0 -0
  384. data/vendor/python/astroid/brain/py2mechanize.py +20 -0
  385. data/vendor/python/astroid/brain/py2mechanize.pyc +0 -0
  386. data/vendor/python/astroid/brain/py2qt4.py +25 -0
  387. data/vendor/python/astroid/brain/py2qt4.pyc +0 -0
  388. data/vendor/python/astroid/brain/py2stdlib.py +252 -0
  389. data/vendor/python/astroid/brain/py2stdlib.pyc +0 -0
  390. data/vendor/python/astroid/builder.py +238 -0
  391. data/vendor/python/astroid/builder.pyc +0 -0
  392. data/vendor/python/astroid/exceptions.py +51 -0
  393. data/vendor/python/astroid/exceptions.pyc +0 -0
  394. data/vendor/python/astroid/inference.py +393 -0
  395. data/vendor/python/astroid/inference.pyc +0 -0
  396. data/vendor/python/astroid/inspector.py +275 -0
  397. data/vendor/python/astroid/manager.py +336 -0
  398. data/vendor/python/astroid/manager.pyc +0 -0
  399. data/vendor/python/astroid/mixins.py +122 -0
  400. data/vendor/python/astroid/mixins.pyc +0 -0
  401. data/vendor/python/astroid/node_classes.py +928 -0
  402. data/vendor/python/astroid/node_classes.pyc +0 -0
  403. data/vendor/python/astroid/nodes.py +73 -0
  404. data/vendor/python/astroid/nodes.pyc +0 -0
  405. data/vendor/python/astroid/protocols.py +322 -0
  406. data/vendor/python/astroid/protocols.pyc +0 -0
  407. data/vendor/python/astroid/raw_building.py +361 -0
  408. data/vendor/python/astroid/raw_building.pyc +0 -0
  409. data/vendor/python/astroid/rebuilder.py +954 -0
  410. data/vendor/python/astroid/rebuilder.pyc +0 -0
  411. data/vendor/python/astroid/scoped_nodes.py +1118 -0
  412. data/vendor/python/astroid/scoped_nodes.pyc +0 -0
  413. data/vendor/python/astroid/setup.py +184 -0
  414. data/vendor/python/astroid/tox.ini +10 -0
  415. data/vendor/python/astroid/utils.py +236 -0
  416. data/vendor/python/astroid/utils.pyc +0 -0
  417. data/vendor/python/logilab/__init__.py +0 -0
  418. data/vendor/python/logilab/__init__.pyc +0 -0
  419. data/vendor/python/logilab/common/COPYING +339 -0
  420. data/vendor/python/logilab/common/COPYING.LESSER +510 -0
  421. data/vendor/python/logilab/common/ChangeLog +1517 -0
  422. data/vendor/python/logilab/common/MANIFEST.in +13 -0
  423. data/vendor/python/logilab/common/README +185 -0
  424. data/vendor/python/logilab/common/README.Python3 +29 -0
  425. data/vendor/python/logilab/common/__init__.py +171 -0
  426. data/vendor/python/logilab/common/__init__.pyc +0 -0
  427. data/vendor/python/logilab/common/__pkginfo__.py +53 -0
  428. data/vendor/python/logilab/common/__pkginfo__.pyc +0 -0
  429. data/vendor/python/logilab/common/announce.txt +25 -0
  430. data/vendor/python/logilab/common/bin/pytest +7 -0
  431. data/vendor/python/logilab/common/bin/pytest.bat +17 -0
  432. data/vendor/python/logilab/common/cache.py +114 -0
  433. data/vendor/python/logilab/common/changelog.py +236 -0
  434. data/vendor/python/logilab/common/changelog.pyc +0 -0
  435. data/vendor/python/logilab/common/clcommands.py +332 -0
  436. data/vendor/python/logilab/common/cli.py +208 -0
  437. data/vendor/python/logilab/common/compat.py +243 -0
  438. data/vendor/python/logilab/common/compat.pyc +0 -0
  439. data/vendor/python/logilab/common/configuration.py +1094 -0
  440. data/vendor/python/logilab/common/configuration.pyc +0 -0
  441. data/vendor/python/logilab/common/contexts.py +5 -0
  442. data/vendor/python/logilab/common/corbautils.py +117 -0
  443. data/vendor/python/logilab/common/daemon.py +100 -0
  444. data/vendor/python/logilab/common/date.py +333 -0
  445. data/vendor/python/logilab/common/dbf.py +229 -0
  446. data/vendor/python/logilab/common/debugger.py +210 -0
  447. data/vendor/python/logilab/common/decorators.py +281 -0
  448. data/vendor/python/logilab/common/decorators.pyc +0 -0
  449. data/vendor/python/logilab/common/deprecation.py +188 -0
  450. data/vendor/python/logilab/common/deprecation.pyc +0 -0
  451. data/vendor/python/logilab/common/fileutils.py +402 -0
  452. data/vendor/python/logilab/common/graph.py +276 -0
  453. data/vendor/python/logilab/common/graph.pyc +0 -0
  454. data/vendor/python/logilab/common/hg.py +130 -0
  455. data/vendor/python/logilab/common/interface.py +71 -0
  456. data/vendor/python/logilab/common/interface.pyc +0 -0
  457. data/vendor/python/logilab/common/logging_ext.py +193 -0
  458. data/vendor/python/logilab/common/modutils.py +695 -0
  459. data/vendor/python/logilab/common/modutils.pyc +0 -0
  460. data/vendor/python/logilab/common/optik_ext.py +391 -0
  461. data/vendor/python/logilab/common/optik_ext.pyc +0 -0
  462. data/vendor/python/logilab/common/optparser.py +90 -0
  463. data/vendor/python/logilab/common/proc.py +277 -0
  464. data/vendor/python/logilab/common/pyro_ext.py +180 -0
  465. data/vendor/python/logilab/common/pytest.py +1177 -0
  466. data/vendor/python/logilab/common/python-logilab-common.spec +184 -0
  467. data/vendor/python/logilab/common/registry.py +1113 -0
  468. data/vendor/python/logilab/common/setup.cfg +3 -0
  469. data/vendor/python/logilab/common/setup.py +189 -0
  470. data/vendor/python/logilab/common/shellutils.py +455 -0
  471. data/vendor/python/logilab/common/sphinx_ext.py +87 -0
  472. data/vendor/python/logilab/common/sphinxutils.py +122 -0
  473. data/vendor/python/logilab/common/table.py +925 -0
  474. data/vendor/python/logilab/common/tasksqueue.py +100 -0
  475. data/vendor/python/logilab/common/textutils.py +534 -0
  476. data/vendor/python/logilab/common/textutils.pyc +0 -0
  477. data/vendor/python/logilab/common/tree.py +369 -0
  478. data/vendor/python/logilab/common/tree.pyc +0 -0
  479. data/vendor/python/logilab/common/umessage.py +190 -0
  480. data/vendor/python/logilab/common/ureports/__init__.py +174 -0
  481. data/vendor/python/logilab/common/ureports/__init__.pyc +0 -0
  482. data/vendor/python/logilab/common/ureports/docbook_writer.py +139 -0
  483. data/vendor/python/logilab/common/ureports/html_writer.py +131 -0
  484. data/vendor/python/logilab/common/ureports/html_writer.pyc +0 -0
  485. data/vendor/python/logilab/common/ureports/nodes.py +201 -0
  486. data/vendor/python/logilab/common/ureports/nodes.pyc +0 -0
  487. data/vendor/python/logilab/common/ureports/text_writer.py +140 -0
  488. data/vendor/python/logilab/common/ureports/text_writer.pyc +0 -0
  489. data/vendor/python/logilab/common/urllib2ext.py +87 -0
  490. data/vendor/python/logilab/common/vcgutils.py +216 -0
  491. data/vendor/python/logilab/common/visitor.py +107 -0
  492. data/vendor/python/logilab/common/visitor.pyc +0 -0
  493. data/vendor/python/logilab/common/xmlrpcutils.py +131 -0
  494. data/vendor/python/logilab/common/xmlutils.py +61 -0
  495. data/vendor/python/pylint/CONTRIBUTORS.txt +38 -0
  496. data/vendor/python/pylint/COPYING +340 -0
  497. data/vendor/python/pylint/ChangeLog +1437 -0
  498. data/vendor/python/pylint/DEPENDS +3 -0
  499. data/vendor/python/pylint/MANIFEST.in +14 -0
  500. data/vendor/python/pylint/README +50 -0
  501. data/vendor/python/pylint/README.Python3 +37 -0
  502. data/vendor/python/pylint/__init__.py +44 -0
  503. data/vendor/python/pylint/__init__.pyc +0 -0
  504. data/vendor/python/pylint/__main__.py +3 -0
  505. data/vendor/python/pylint/__pkginfo__.py +74 -0
  506. data/vendor/python/pylint/__pkginfo__.pyc +0 -0
  507. data/vendor/python/pylint/bin/epylint +3 -0
  508. data/vendor/python/pylint/bin/epylint.bat +5 -0
  509. data/vendor/python/pylint/bin/pylint +3 -0
  510. data/vendor/python/pylint/bin/pylint-gui +3 -0
  511. data/vendor/python/pylint/bin/pylint-gui.bat +5 -0
  512. data/vendor/python/pylint/bin/pylint.bat +5 -0
  513. data/vendor/python/pylint/bin/pyreverse +3 -0
  514. data/vendor/python/pylint/bin/pyreverse.bat +5 -0
  515. data/vendor/python/pylint/bin/symilar +3 -0
  516. data/vendor/python/pylint/bin/symilar.bat +5 -0
  517. data/vendor/python/pylint/checkers/__init__.py +145 -0
  518. data/vendor/python/pylint/checkers/__init__.pyc +0 -0
  519. data/vendor/python/pylint/checkers/base.py +1141 -0
  520. data/vendor/python/pylint/checkers/base.pyc +0 -0
  521. data/vendor/python/pylint/checkers/classes.py +792 -0
  522. data/vendor/python/pylint/checkers/classes.pyc +0 -0
  523. data/vendor/python/pylint/checkers/design_analysis.py +367 -0
  524. data/vendor/python/pylint/checkers/design_analysis.pyc +0 -0
  525. data/vendor/python/pylint/checkers/exceptions.py +306 -0
  526. data/vendor/python/pylint/checkers/exceptions.pyc +0 -0
  527. data/vendor/python/pylint/checkers/format.py +943 -0
  528. data/vendor/python/pylint/checkers/format.pyc +0 -0
  529. data/vendor/python/pylint/checkers/imports.py +394 -0
  530. data/vendor/python/pylint/checkers/imports.pyc +0 -0
  531. data/vendor/python/pylint/checkers/logging.py +213 -0
  532. data/vendor/python/pylint/checkers/logging.pyc +0 -0
  533. data/vendor/python/pylint/checkers/misc.py +90 -0
  534. data/vendor/python/pylint/checkers/misc.pyc +0 -0
  535. data/vendor/python/pylint/checkers/newstyle.py +151 -0
  536. data/vendor/python/pylint/checkers/newstyle.pyc +0 -0
  537. data/vendor/python/pylint/checkers/raw_metrics.py +129 -0
  538. data/vendor/python/pylint/checkers/raw_metrics.pyc +0 -0
  539. data/vendor/python/pylint/checkers/similar.py +365 -0
  540. data/vendor/python/pylint/checkers/similar.pyc +0 -0
  541. data/vendor/python/pylint/checkers/stdlib.py +69 -0
  542. data/vendor/python/pylint/checkers/stdlib.pyc +0 -0
  543. data/vendor/python/pylint/checkers/strings.py +304 -0
  544. data/vendor/python/pylint/checkers/strings.pyc +0 -0
  545. data/vendor/python/pylint/checkers/typecheck.py +451 -0
  546. data/vendor/python/pylint/checkers/typecheck.pyc +0 -0
  547. data/vendor/python/pylint/checkers/utils.py +416 -0
  548. data/vendor/python/pylint/checkers/utils.pyc +0 -0
  549. data/vendor/python/pylint/checkers/variables.py +741 -0
  550. data/vendor/python/pylint/checkers/variables.pyc +0 -0
  551. data/vendor/python/pylint/config.py +156 -0
  552. data/vendor/python/pylint/config.pyc +0 -0
  553. data/vendor/python/pylint/epylint.py +175 -0
  554. data/vendor/python/pylint/gui.py +508 -0
  555. data/vendor/python/pylint/interfaces.py +72 -0
  556. data/vendor/python/pylint/interfaces.pyc +0 -0
  557. data/vendor/python/pylint/lint.py +1106 -0
  558. data/vendor/python/pylint/lint.pyc +0 -0
  559. data/vendor/python/pylint/pyreverse/__init__.py +5 -0
  560. data/vendor/python/pylint/pyreverse/diadefslib.py +233 -0
  561. data/vendor/python/pylint/pyreverse/diagrams.py +247 -0
  562. data/vendor/python/pylint/pyreverse/main.py +124 -0
  563. data/vendor/python/pylint/pyreverse/utils.py +131 -0
  564. data/vendor/python/pylint/pyreverse/writer.py +199 -0
  565. data/vendor/python/pylint/reporters/__init__.py +138 -0
  566. data/vendor/python/pylint/reporters/__init__.pyc +0 -0
  567. data/vendor/python/pylint/reporters/guireporter.py +28 -0
  568. data/vendor/python/pylint/reporters/guireporter.pyc +0 -0
  569. data/vendor/python/pylint/reporters/html.py +70 -0
  570. data/vendor/python/pylint/reporters/html.pyc +0 -0
  571. data/vendor/python/pylint/reporters/text.py +143 -0
  572. data/vendor/python/pylint/reporters/text.pyc +0 -0
  573. data/vendor/python/pylint/setup.cfg +3 -0
  574. data/vendor/python/pylint/setup.py +203 -0
  575. data/vendor/python/pylint/tox.ini +10 -0
  576. data/vendor/python/pylint/utils.py +744 -0
  577. data/vendor/python/pylint/utils.pyc +0 -0
  578. data/vendor/python/pylint_runner.py +22 -0
  579. metadata +675 -0
@@ -0,0 +1,416 @@
1
+ # pylint: disable=W0611
2
+ #
3
+ # Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE).
4
+ # http://www.logilab.fr/ -- mailto:contact@logilab.fr
5
+ #
6
+ # This program is free software; you can redistribute it and/or modify it under
7
+ # the terms of the GNU General Public License as published by the Free Software
8
+ # Foundation; either version 2 of the License, or (at your option) any later
9
+ # version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License along with
16
+ # this program; if not, write to the Free Software Foundation, Inc.,
17
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
+ """some functions that may be useful for various checkers
19
+ """
20
+
21
+ import re
22
+ import string
23
+
24
+ import astroid
25
+ from astroid import scoped_nodes
26
+ from logilab.common.compat import builtins
27
+
28
+ BUILTINS_NAME = builtins.__name__
29
+
30
+ COMP_NODE_TYPES = astroid.ListComp, astroid.SetComp, astroid.DictComp, astroid.GenExpr
31
+
32
+
33
+ class NoSuchArgumentError(Exception):
34
+ pass
35
+
36
+ def is_inside_except(node):
37
+ """Returns true if node is inside the name of an except handler."""
38
+ current = node
39
+ while current and not isinstance(current.parent, astroid.ExceptHandler):
40
+ current = current.parent
41
+
42
+ return current and current is current.parent.name
43
+
44
+
45
+ def get_all_elements(node):
46
+ """Recursively returns all atoms in nested lists and tuples."""
47
+ if isinstance(node, (astroid.Tuple, astroid.List)):
48
+ for child in node.elts:
49
+ for e in get_all_elements(child):
50
+ yield e
51
+ else:
52
+ yield node
53
+
54
+
55
+ def clobber_in_except(node):
56
+ """Checks if an assignment node in an except handler clobbers an existing
57
+ variable.
58
+
59
+ Returns (True, args for W0623) if assignment clobbers an existing variable,
60
+ (False, None) otherwise.
61
+ """
62
+ if isinstance(node, astroid.AssAttr):
63
+ return (True, (node.attrname, 'object %r' % (node.expr.as_string(),)))
64
+ elif isinstance(node, astroid.AssName):
65
+ name = node.name
66
+ if is_builtin(name):
67
+ return (True, (name, 'builtins'))
68
+ else:
69
+ scope, stmts = node.lookup(name)
70
+ if (stmts and
71
+ not isinstance(stmts[0].ass_type(),
72
+ (astroid.Assign, astroid.AugAssign,
73
+ astroid.ExceptHandler))):
74
+ return (True, (name, 'outer scope (line %s)' % stmts[0].fromlineno))
75
+ return (False, None)
76
+
77
+
78
+ def safe_infer(node):
79
+ """return the inferred value for the given node.
80
+ Return None if inference failed or if there is some ambiguity (more than
81
+ one node has been inferred)
82
+ """
83
+ try:
84
+ inferit = node.infer()
85
+ value = inferit.next()
86
+ except astroid.InferenceError:
87
+ return
88
+ try:
89
+ inferit.next()
90
+ return # None if there is ambiguity on the inferred node
91
+ except astroid.InferenceError:
92
+ return # there is some kind of ambiguity
93
+ except StopIteration:
94
+ return value
95
+
96
+ def is_super(node):
97
+ """return True if the node is referencing the "super" builtin function
98
+ """
99
+ if getattr(node, 'name', None) == 'super' and \
100
+ node.root().name == BUILTINS_NAME:
101
+ return True
102
+ return False
103
+
104
+ def is_error(node):
105
+ """return true if the function does nothing but raising an exception"""
106
+ for child_node in node.get_children():
107
+ if isinstance(child_node, astroid.Raise):
108
+ return True
109
+ return False
110
+
111
+ def is_raising(body):
112
+ """return true if the given statement node raise an exception"""
113
+ for node in body:
114
+ if isinstance(node, astroid.Raise):
115
+ return True
116
+ return False
117
+
118
+ def is_empty(body):
119
+ """return true if the given node does nothing but 'pass'"""
120
+ return len(body) == 1 and isinstance(body[0], astroid.Pass)
121
+
122
+ builtins = builtins.__dict__.copy()
123
+ SPECIAL_BUILTINS = ('__builtins__',) # '__path__', '__file__')
124
+
125
+ def is_builtin_object(node):
126
+ """Returns True if the given node is an object from the __builtin__ module."""
127
+ return node and node.root().name == BUILTINS_NAME
128
+
129
+ def is_builtin(name): # was is_native_builtin
130
+ """return true if <name> could be considered as a builtin defined by python
131
+ """
132
+ if name in builtins:
133
+ return True
134
+ if name in SPECIAL_BUILTINS:
135
+ return True
136
+ return False
137
+
138
+ def is_defined_before(var_node):
139
+ """return True if the variable node is defined by a parent node (list,
140
+ set, dict, or generator comprehension, lambda) or in a previous sibling
141
+ node on the same line (statement_defining ; statement_using)
142
+ """
143
+ varname = var_node.name
144
+ _node = var_node.parent
145
+ while _node:
146
+ if isinstance(_node, COMP_NODE_TYPES):
147
+ for ass_node in _node.nodes_of_class(astroid.AssName):
148
+ if ass_node.name == varname:
149
+ return True
150
+ elif isinstance(_node, astroid.For):
151
+ for ass_node in _node.target.nodes_of_class(astroid.AssName):
152
+ if ass_node.name == varname:
153
+ return True
154
+ elif isinstance(_node, astroid.With):
155
+ for expr, vars in _node.items:
156
+ if expr.parent_of(var_node):
157
+ break
158
+ if (vars and
159
+ isinstance(vars, astroid.AssName) and
160
+ vars.name == varname):
161
+ return True
162
+ elif isinstance(_node, (astroid.Lambda, astroid.Function)):
163
+ if _node.args.is_argument(varname):
164
+ return True
165
+ if getattr(_node, 'name', None) == varname:
166
+ return True
167
+ break
168
+ elif isinstance(_node, astroid.ExceptHandler):
169
+ if isinstance(_node.name, astroid.AssName):
170
+ ass_node = _node.name
171
+ if ass_node.name == varname:
172
+ return True
173
+ _node = _node.parent
174
+ # possibly multiple statements on the same line using semi colon separator
175
+ stmt = var_node.statement()
176
+ _node = stmt.previous_sibling()
177
+ lineno = stmt.fromlineno
178
+ while _node and _node.fromlineno == lineno:
179
+ for ass_node in _node.nodes_of_class(astroid.AssName):
180
+ if ass_node.name == varname:
181
+ return True
182
+ for imp_node in _node.nodes_of_class((astroid.From, astroid.Import)):
183
+ if varname in [name[1] or name[0] for name in imp_node.names]:
184
+ return True
185
+ _node = _node.previous_sibling()
186
+ return False
187
+
188
+ def is_func_default(node):
189
+ """return true if the given Name node is used in function default argument's
190
+ value
191
+ """
192
+ parent = node.scope()
193
+ if isinstance(parent, astroid.Function):
194
+ for default_node in parent.args.defaults:
195
+ for default_name_node in default_node.nodes_of_class(astroid.Name):
196
+ if default_name_node is node:
197
+ return True
198
+ return False
199
+
200
+ def is_func_decorator(node):
201
+ """return true if the name is used in function decorator"""
202
+ parent = node.parent
203
+ while parent is not None:
204
+ if isinstance(parent, astroid.Decorators):
205
+ return True
206
+ if (parent.is_statement or
207
+ isinstance(parent, astroid.Lambda) or
208
+ isinstance(parent, (scoped_nodes.ComprehensionScope,
209
+ scoped_nodes.ListComp))):
210
+ break
211
+ parent = parent.parent
212
+ return False
213
+
214
+ def is_ancestor_name(frame, node):
215
+ """return True if `frame` is a astroid.Class node with `node` in the
216
+ subtree of its bases attribute
217
+ """
218
+ try:
219
+ bases = frame.bases
220
+ except AttributeError:
221
+ return False
222
+ for base in bases:
223
+ if node in base.nodes_of_class(astroid.Name):
224
+ return True
225
+ return False
226
+
227
+ def assign_parent(node):
228
+ """return the higher parent which is not an AssName, Tuple or List node
229
+ """
230
+ while node and isinstance(node, (astroid.AssName,
231
+ astroid.Tuple,
232
+ astroid.List)):
233
+ node = node.parent
234
+ return node
235
+
236
+ def overrides_an_abstract_method(class_node, name):
237
+ """return True if pnode is a parent of node"""
238
+ for ancestor in class_node.ancestors():
239
+ if name in ancestor and isinstance(ancestor[name], astroid.Function) and \
240
+ ancestor[name].is_abstract(pass_is_abstract=False):
241
+ return True
242
+ return False
243
+
244
+ def overrides_a_method(class_node, name):
245
+ """return True if <name> is a method overridden from an ancestor"""
246
+ for ancestor in class_node.ancestors():
247
+ if name in ancestor and isinstance(ancestor[name], astroid.Function):
248
+ return True
249
+ return False
250
+
251
+ PYMETHODS = set(('__new__', '__init__', '__del__', '__hash__',
252
+ '__str__', '__repr__',
253
+ '__len__', '__iter__',
254
+ '__delete__', '__get__', '__set__',
255
+ '__getitem__', '__setitem__', '__delitem__', '__contains__',
256
+ '__getattribute__', '__getattr__', '__setattr__', '__delattr__',
257
+ '__call__',
258
+ '__enter__', '__exit__',
259
+ '__cmp__', '__ge__', '__gt__', '__le__', '__lt__', '__eq__',
260
+ '__nonzero__', '__neg__', '__invert__',
261
+ '__mul__', '__imul__', '__rmul__',
262
+ '__div__', '__idiv__', '__rdiv__',
263
+ '__add__', '__iadd__', '__radd__',
264
+ '__sub__', '__isub__', '__rsub__',
265
+ '__pow__', '__ipow__', '__rpow__',
266
+ '__mod__', '__imod__', '__rmod__',
267
+ '__and__', '__iand__', '__rand__',
268
+ '__or__', '__ior__', '__ror__',
269
+ '__xor__', '__ixor__', '__rxor__',
270
+ # XXX To be continued
271
+ ))
272
+
273
+ def check_messages(*messages):
274
+ """decorator to store messages that are handled by a checker method"""
275
+
276
+ def store_messages(func):
277
+ func.checks_msgs = messages
278
+ return func
279
+ return store_messages
280
+
281
+ class IncompleteFormatString(Exception):
282
+ """A format string ended in the middle of a format specifier."""
283
+ pass
284
+
285
+ class UnsupportedFormatCharacter(Exception):
286
+ """A format character in a format string is not one of the supported
287
+ format characters."""
288
+ def __init__(self, index):
289
+ Exception.__init__(self, index)
290
+ self.index = index
291
+
292
+ def parse_format_string(format_string):
293
+ """Parses a format string, returning a tuple of (keys, num_args), where keys
294
+ is the set of mapping keys in the format string, and num_args is the number
295
+ of arguments required by the format string. Raises
296
+ IncompleteFormatString or UnsupportedFormatCharacter if a
297
+ parse error occurs."""
298
+ keys = set()
299
+ num_args = 0
300
+ def next_char(i):
301
+ i += 1
302
+ if i == len(format_string):
303
+ raise IncompleteFormatString
304
+ return (i, format_string[i])
305
+ i = 0
306
+ while i < len(format_string):
307
+ char = format_string[i]
308
+ if char == '%':
309
+ i, char = next_char(i)
310
+ # Parse the mapping key (optional).
311
+ key = None
312
+ if char == '(':
313
+ depth = 1
314
+ i, char = next_char(i)
315
+ key_start = i
316
+ while depth != 0:
317
+ if char == '(':
318
+ depth += 1
319
+ elif char == ')':
320
+ depth -= 1
321
+ i, char = next_char(i)
322
+ key_end = i - 1
323
+ key = format_string[key_start:key_end]
324
+
325
+ # Parse the conversion flags (optional).
326
+ while char in '#0- +':
327
+ i, char = next_char(i)
328
+ # Parse the minimum field width (optional).
329
+ if char == '*':
330
+ num_args += 1
331
+ i, char = next_char(i)
332
+ else:
333
+ while char in string.digits:
334
+ i, char = next_char(i)
335
+ # Parse the precision (optional).
336
+ if char == '.':
337
+ i, char = next_char(i)
338
+ if char == '*':
339
+ num_args += 1
340
+ i, char = next_char(i)
341
+ else:
342
+ while char in string.digits:
343
+ i, char = next_char(i)
344
+ # Parse the length modifier (optional).
345
+ if char in 'hlL':
346
+ i, char = next_char(i)
347
+ # Parse the conversion type (mandatory).
348
+ if char not in 'diouxXeEfFgGcrs%':
349
+ raise UnsupportedFormatCharacter(i)
350
+ if key:
351
+ keys.add(key)
352
+ elif char != '%':
353
+ num_args += 1
354
+ i += 1
355
+ return keys, num_args
356
+
357
+ def is_attr_protected(attrname):
358
+ """return True if attribute name is protected (start with _ and some other
359
+ details), False otherwise.
360
+ """
361
+ return attrname[0] == '_' and not attrname == '_' and not (
362
+ attrname.startswith('__') and attrname.endswith('__'))
363
+
364
+ def node_frame_class(node):
365
+ """return klass node for a method node (or a staticmethod or a
366
+ classmethod), return null otherwise
367
+ """
368
+ klass = node.frame()
369
+
370
+ while klass is not None and not isinstance(klass, astroid.Class):
371
+ if klass.parent is None:
372
+ klass = None
373
+ else:
374
+ klass = klass.parent.frame()
375
+
376
+ return klass
377
+
378
+ def is_super_call(expr):
379
+ """return True if expression node is a function call and if function name
380
+ is super. Check before that you're in a method.
381
+ """
382
+ return (isinstance(expr, astroid.CallFunc) and
383
+ isinstance(expr.func, astroid.Name) and
384
+ expr.func.name == 'super')
385
+
386
+ def is_attr_private(attrname):
387
+ """Check that attribute name is private (at least two leading underscores,
388
+ at most one trailing underscore)
389
+ """
390
+ regex = re.compile('^_{2,}.*[^_]+_?$')
391
+ return regex.match(attrname)
392
+
393
+ def get_argument_from_call(callfunc_node, position=None, keyword=None):
394
+ """Returns the specified argument from a function call.
395
+
396
+ :param callfunc_node: Node representing a function call to check.
397
+ :param int position: position of the argument.
398
+ :param str keyword: the keyword of the argument.
399
+
400
+ :returns: The node representing the argument, None if the argument is not found.
401
+ :raises ValueError: if both position and keyword are None.
402
+ :raises NoSuchArgumentError: if no argument at the provided position or with
403
+ the provided keyword.
404
+ """
405
+ if position is None and keyword is None:
406
+ raise ValueError('Must specify at least one of: position or keyword.')
407
+ try:
408
+ if position is not None and not isinstance(callfunc_node.args[position], astroid.Keyword):
409
+ return callfunc_node.args[position]
410
+ except IndexError, error:
411
+ raise NoSuchArgumentError(error)
412
+ if keyword:
413
+ for arg in callfunc_node.args:
414
+ if isinstance(arg, astroid.Keyword) and arg.arg == keyword:
415
+ return arg.value
416
+ raise NoSuchArgumentError
@@ -0,0 +1,741 @@
1
+ # Copyright (c) 2003-2014 LOGILAB S.A. (Paris, FRANCE).
2
+ # http://www.logilab.fr/ -- mailto:contact@logilab.fr
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify it under
5
+ # the terms of the GNU General Public License as published by the Free Software
6
+ # Foundation; either version 2 of the License, or (at your option) any later
7
+ # version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
+ # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along with
14
+ # this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
+ """variables checkers for Python code
17
+ """
18
+ import os
19
+ import sys
20
+ from copy import copy
21
+
22
+ import astroid
23
+ from astroid import are_exclusive, builtin_lookup, AstroidBuildingException
24
+
25
+ from logilab.common.modutils import file_from_modpath
26
+
27
+ from pylint.interfaces import IAstroidChecker
28
+ from pylint.checkers import BaseChecker
29
+ from pylint.checkers.utils import (PYMETHODS, is_ancestor_name, is_builtin,
30
+ is_defined_before, is_error, is_func_default, is_func_decorator,
31
+ assign_parent, check_messages, is_inside_except, clobber_in_except,
32
+ get_all_elements)
33
+
34
+
35
+ def in_for_else_branch(parent, stmt):
36
+ """Returns True if stmt in inside the else branch for a parent For stmt."""
37
+ return (isinstance(parent, astroid.For) and
38
+ any(else_stmt.parent_of(stmt) for else_stmt in parent.orelse))
39
+
40
+ def overridden_method(klass, name):
41
+ """get overridden method if any"""
42
+ try:
43
+ parent = klass.local_attr_ancestors(name).next()
44
+ except (StopIteration, KeyError):
45
+ return None
46
+ try:
47
+ meth_node = parent[name]
48
+ except KeyError:
49
+ # We have found an ancestor defining <name> but it's not in the local
50
+ # dictionary. This may happen with astroid built from living objects.
51
+ return None
52
+ if isinstance(meth_node, astroid.Function):
53
+ return meth_node
54
+ return None
55
+
56
+ def _get_unpacking_extra_info(node, infered):
57
+ """return extra information to add to the message for unpacking-non-sequence
58
+ and unbalanced-tuple-unpacking errors
59
+ """
60
+ more = ''
61
+ infered_module = infered.root().name
62
+ if node.root().name == infered_module:
63
+ if node.lineno == infered.lineno:
64
+ more = ' %s' % infered.as_string()
65
+ elif infered.lineno:
66
+ more = ' defined at line %s' % infered.lineno
67
+ elif infered.lineno:
68
+ more = ' defined at line %s of %s' % (infered.lineno, infered_module)
69
+ return more
70
+
71
+ MSGS = {
72
+ 'E0601': ('Using variable %r before assignment',
73
+ 'used-before-assignment',
74
+ 'Used when a local variable is accessed before it\'s \
75
+ assignment.'),
76
+ 'E0602': ('Undefined variable %r',
77
+ 'undefined-variable',
78
+ 'Used when an undefined variable is accessed.'),
79
+ 'E0603': ('Undefined variable name %r in __all__',
80
+ 'undefined-all-variable',
81
+ 'Used when an undefined variable name is referenced in __all__.'),
82
+ 'E0604': ('Invalid object %r in __all__, must contain only strings',
83
+ 'invalid-all-object',
84
+ 'Used when an invalid (non-string) object occurs in __all__.'),
85
+ 'E0611': ('No name %r in module %r',
86
+ 'no-name-in-module',
87
+ 'Used when a name cannot be found in a module.'),
88
+
89
+ 'W0601': ('Global variable %r undefined at the module level',
90
+ 'global-variable-undefined',
91
+ 'Used when a variable is defined through the "global" statement \
92
+ but the variable is not defined in the module scope.'),
93
+ 'W0602': ('Using global for %r but no assignment is done',
94
+ 'global-variable-not-assigned',
95
+ 'Used when a variable is defined through the "global" statement \
96
+ but no assignment to this variable is done.'),
97
+ 'W0603': ('Using the global statement', # W0121
98
+ 'global-statement',
99
+ 'Used when you use the "global" statement to update a global \
100
+ variable. PyLint just try to discourage this \
101
+ usage. That doesn\'t mean you can not use it !'),
102
+ 'W0604': ('Using the global statement at the module level', # W0103
103
+ 'global-at-module-level',
104
+ 'Used when you use the "global" statement at the module level \
105
+ since it has no effect'),
106
+ 'W0611': ('Unused import %s',
107
+ 'unused-import',
108
+ 'Used when an imported module or variable is not used.'),
109
+ 'W0612': ('Unused variable %r',
110
+ 'unused-variable',
111
+ 'Used when a variable is defined but not used.'),
112
+ 'W0613': ('Unused argument %r',
113
+ 'unused-argument',
114
+ 'Used when a function or method argument is not used.'),
115
+ 'W0614': ('Unused import %s from wildcard import',
116
+ 'unused-wildcard-import',
117
+ 'Used when an imported module or variable is not used from a \
118
+ \'from X import *\' style import.'),
119
+
120
+ 'W0621': ('Redefining name %r from outer scope (line %s)',
121
+ 'redefined-outer-name',
122
+ 'Used when a variable\'s name hide a name defined in the outer \
123
+ scope.'),
124
+ 'W0622': ('Redefining built-in %r',
125
+ 'redefined-builtin',
126
+ 'Used when a variable or function override a built-in.'),
127
+ 'W0623': ('Redefining name %r from %s in exception handler',
128
+ 'redefine-in-handler',
129
+ 'Used when an exception handler assigns the exception \
130
+ to an existing name'),
131
+
132
+ 'W0631': ('Using possibly undefined loop variable %r',
133
+ 'undefined-loop-variable',
134
+ 'Used when an loop variable (i.e. defined by a for loop or \
135
+ a list comprehension or a generator expression) is used outside \
136
+ the loop.'),
137
+
138
+ 'W0632': ('Possible unbalanced tuple unpacking with '
139
+ 'sequence%s: '
140
+ 'left side has %d label(s), right side has %d value(s)',
141
+ 'unbalanced-tuple-unpacking',
142
+ 'Used when there is an unbalanced tuple unpacking in assignment'),
143
+
144
+ 'W0633': ('Attempting to unpack a non-sequence%s',
145
+ 'unpacking-non-sequence',
146
+ 'Used when something which is not '
147
+ 'a sequence is used in an unpack assignment'),
148
+
149
+ 'W0640': ('Cell variable %s defined in loop',
150
+ 'cell-var-from-loop',
151
+ 'A variable used in a closure is defined in a loop. '
152
+ 'This will result in all closures using the same value for '
153
+ 'the closed-over variable.'),
154
+
155
+ }
156
+
157
+ class VariablesChecker(BaseChecker):
158
+ """checks for
159
+ * unused variables / imports
160
+ * undefined variables
161
+ * redefinition of variable from builtins or from an outer scope
162
+ * use of variable before assignment
163
+ * __all__ consistency
164
+ """
165
+
166
+ __implements__ = IAstroidChecker
167
+
168
+ name = 'variables'
169
+ msgs = MSGS
170
+ priority = -1
171
+ options = (
172
+ ("init-import",
173
+ {'default': 0, 'type' : 'yn', 'metavar' : '<y_or_n>',
174
+ 'help' : 'Tells whether we should check for unused import in \
175
+ __init__ files.'}),
176
+ ("dummy-variables-rgx",
177
+ {'default': ('_$|dummy'),
178
+ 'type' :'regexp', 'metavar' : '<regexp>',
179
+ 'help' : 'A regular expression matching the name of dummy \
180
+ variables (i.e. expectedly not used).'}),
181
+ ("additional-builtins",
182
+ {'default': (), 'type' : 'csv',
183
+ 'metavar' : '<comma separated list>',
184
+ 'help' : 'List of additional names supposed to be defined in \
185
+ builtins. Remember that you should avoid to define new builtins when possible.'
186
+ }),
187
+ )
188
+ def __init__(self, linter=None):
189
+ BaseChecker.__init__(self, linter)
190
+ self._to_consume = None
191
+ self._checking_mod_attr = None
192
+
193
+ def visit_module(self, node):
194
+ """visit module : update consumption analysis variable
195
+ checks globals doesn't overrides builtins
196
+ """
197
+ self._to_consume = [(copy(node.locals), {}, 'module')]
198
+ for name, stmts in node.locals.iteritems():
199
+ if is_builtin(name) and not is_inside_except(stmts[0]):
200
+ # do not print Redefining builtin for additional builtins
201
+ self.add_message('redefined-builtin', args=name, node=stmts[0])
202
+
203
+ @check_messages('unused-import', 'unused-wildcard-import', 'redefined-builtin', 'undefined-all-variable', 'invalid-all-object')
204
+ def leave_module(self, node):
205
+ """leave module: check globals
206
+ """
207
+ assert len(self._to_consume) == 1
208
+ not_consumed = self._to_consume.pop()[0]
209
+ # attempt to check for __all__ if defined
210
+ if '__all__' in node.locals:
211
+ assigned = node.igetattr('__all__').next()
212
+ if assigned is not astroid.YES:
213
+ for elt in getattr(assigned, 'elts', ()):
214
+ try:
215
+ elt_name = elt.infer().next()
216
+ except astroid.InferenceError:
217
+ continue
218
+
219
+ if not isinstance(elt_name, astroid.Const) \
220
+ or not isinstance(elt_name.value, basestring):
221
+ self.add_message('invalid-all-object', args=elt.as_string(), node=elt)
222
+ continue
223
+ elt_name = elt_name.value
224
+ # If elt is in not_consumed, remove it from not_consumed
225
+ if elt_name in not_consumed:
226
+ del not_consumed[elt_name]
227
+ continue
228
+ if elt_name not in node.locals:
229
+ if not node.package:
230
+ self.add_message('undefined-all-variable',
231
+ args=elt_name,
232
+ node=elt)
233
+ else:
234
+ basename = os.path.splitext(node.file)[0]
235
+ if os.path.basename(basename) == '__init__':
236
+ name = node.name + "." + elt_name
237
+ try:
238
+ file_from_modpath(name.split("."))
239
+ except ImportError:
240
+ self.add_message('undefined-all-variable',
241
+ args=elt_name,
242
+ node=elt)
243
+ except SyntaxError, exc:
244
+ # don't yield an syntax-error warning,
245
+ # because it will be later yielded
246
+ # when the file will be checked
247
+ pass
248
+ # don't check unused imports in __init__ files
249
+ if not self.config.init_import and node.package:
250
+ return
251
+ for name, stmts in not_consumed.iteritems():
252
+ if any(isinstance(stmt, astroid.AssName)
253
+ and isinstance(stmt.ass_type(), astroid.AugAssign)
254
+ for stmt in stmts):
255
+ continue
256
+ stmt = stmts[0]
257
+ if isinstance(stmt, astroid.Import):
258
+ self.add_message('unused-import', args=name, node=stmt)
259
+ elif isinstance(stmt, astroid.From) and stmt.modname != '__future__':
260
+ if stmt.names[0][0] == '*':
261
+ self.add_message('unused-wildcard-import', args=name, node=stmt)
262
+ else:
263
+ self.add_message('unused-import', args=name, node=stmt)
264
+ del self._to_consume
265
+
266
+ def visit_class(self, node):
267
+ """visit class: update consumption analysis variable
268
+ """
269
+ self._to_consume.append((copy(node.locals), {}, 'class'))
270
+
271
+ def leave_class(self, _):
272
+ """leave class: update consumption analysis variable
273
+ """
274
+ # do not check for not used locals here (no sense)
275
+ self._to_consume.pop()
276
+
277
+ def visit_lambda(self, node):
278
+ """visit lambda: update consumption analysis variable
279
+ """
280
+ self._to_consume.append((copy(node.locals), {}, 'lambda'))
281
+
282
+ def leave_lambda(self, _):
283
+ """leave lambda: update consumption analysis variable
284
+ """
285
+ # do not check for not used locals here
286
+ self._to_consume.pop()
287
+
288
+ def visit_genexpr(self, node):
289
+ """visit genexpr: update consumption analysis variable
290
+ """
291
+ self._to_consume.append((copy(node.locals), {}, 'comprehension'))
292
+
293
+ def leave_genexpr(self, _):
294
+ """leave genexpr: update consumption analysis variable
295
+ """
296
+ # do not check for not used locals here
297
+ self._to_consume.pop()
298
+
299
+ def visit_dictcomp(self, node):
300
+ """visit dictcomp: update consumption analysis variable
301
+ """
302
+ self._to_consume.append((copy(node.locals), {}, 'comprehension'))
303
+
304
+ def leave_dictcomp(self, _):
305
+ """leave dictcomp: update consumption analysis variable
306
+ """
307
+ # do not check for not used locals here
308
+ self._to_consume.pop()
309
+
310
+ def visit_setcomp(self, node):
311
+ """visit setcomp: update consumption analysis variable
312
+ """
313
+ self._to_consume.append((copy(node.locals), {}, 'comprehension'))
314
+
315
+ def leave_setcomp(self, _):
316
+ """leave setcomp: update consumption analysis variable
317
+ """
318
+ # do not check for not used locals here
319
+ self._to_consume.pop()
320
+
321
+ def visit_function(self, node):
322
+ """visit function: update consumption analysis variable and check locals
323
+ """
324
+ self._to_consume.append((copy(node.locals), {}, 'function'))
325
+ if not (self.linter.is_message_enabled('redefined-outer-name') or
326
+ self.linter.is_message_enabled('redefined-builtin')):
327
+ return
328
+ globs = node.root().globals
329
+ for name, stmt in node.items():
330
+ if is_inside_except(stmt):
331
+ continue
332
+ if name in globs and not isinstance(stmt, astroid.Global):
333
+ line = globs[name][0].fromlineno
334
+ dummy_rgx = self.config.dummy_variables_rgx
335
+ if not dummy_rgx.match(name):
336
+ self.add_message('redefined-outer-name', args=(name, line), node=stmt)
337
+ elif is_builtin(name):
338
+ # do not print Redefining builtin for additional builtins
339
+ self.add_message('redefined-builtin', args=name, node=stmt)
340
+
341
+ def leave_function(self, node):
342
+ """leave function: check function's locals are consumed"""
343
+ not_consumed = self._to_consume.pop()[0]
344
+ if not (self.linter.is_message_enabled('unused-variable') or
345
+ self.linter.is_message_enabled('unused-argument')):
346
+ return
347
+ # don't check arguments of function which are only raising an exception
348
+ if is_error(node):
349
+ return
350
+ # don't check arguments of abstract methods or within an interface
351
+ is_method = node.is_method()
352
+ klass = node.parent.frame()
353
+ if is_method and (klass.type == 'interface' or node.is_abstract()):
354
+ return
355
+ authorized_rgx = self.config.dummy_variables_rgx
356
+ called_overridden = False
357
+ argnames = node.argnames()
358
+ for name, stmts in not_consumed.iteritems():
359
+ # ignore some special names specified by user configuration
360
+ if authorized_rgx.match(name):
361
+ continue
362
+ # ignore names imported by the global statement
363
+ # FIXME: should only ignore them if it's assigned latter
364
+ stmt = stmts[0]
365
+ if isinstance(stmt, astroid.Global):
366
+ continue
367
+ # care about functions with unknown argument (builtins)
368
+ if name in argnames:
369
+ if is_method:
370
+ # don't warn for the first argument of a (non static) method
371
+ if node.type != 'staticmethod' and name == argnames[0]:
372
+ continue
373
+ # don't warn for argument of an overridden method
374
+ if not called_overridden:
375
+ overridden = overridden_method(klass, node.name)
376
+ called_overridden = True
377
+ if overridden is not None and name in overridden.argnames():
378
+ continue
379
+ if node.name in PYMETHODS and node.name not in ('__init__', '__new__'):
380
+ continue
381
+ # don't check callback arguments XXX should be configurable
382
+ if node.name.startswith('cb_') or node.name.endswith('_cb'):
383
+ continue
384
+ self.add_message('unused-argument', args=name, node=stmt)
385
+ else:
386
+ self.add_message('unused-variable', args=name, node=stmt)
387
+
388
+ @check_messages('global-variable-undefined', 'global-variable-not-assigned', 'global-statement',
389
+ 'global-at-module-level', 'redefined-builtin')
390
+ def visit_global(self, node):
391
+ """check names imported exists in the global scope"""
392
+ frame = node.frame()
393
+ if isinstance(frame, astroid.Module):
394
+ self.add_message('global-at-module-level', node=node)
395
+ return
396
+ module = frame.root()
397
+ default_message = True
398
+ for name in node.names:
399
+ try:
400
+ assign_nodes = module.getattr(name)
401
+ except astroid.NotFoundError:
402
+ # unassigned global, skip
403
+ assign_nodes = []
404
+ for anode in assign_nodes:
405
+ if anode.parent is None:
406
+ # node returned for builtin attribute such as __file__,
407
+ # __doc__, etc...
408
+ continue
409
+ if anode.frame() is frame:
410
+ # same scope level assignment
411
+ break
412
+ else:
413
+ # global but no assignment
414
+ self.add_message('global-variable-not-assigned', args=name, node=node)
415
+ default_message = False
416
+ if not assign_nodes:
417
+ continue
418
+ for anode in assign_nodes:
419
+ if anode.parent is None:
420
+ self.add_message('redefined-builtin', args=name, node=node)
421
+ break
422
+ if anode.frame() is module:
423
+ # module level assignment
424
+ break
425
+ else:
426
+ # global undefined at the module scope
427
+ self.add_message('global-variable-undefined', args=name, node=node)
428
+ default_message = False
429
+ if default_message:
430
+ self.add_message('global-statement', node=node)
431
+
432
+ def _check_late_binding_closure(self, node, assignment_node, scope_type):
433
+ node_scope = node.scope()
434
+ if not isinstance(node_scope, (astroid.Lambda, astroid.Function)):
435
+ return
436
+
437
+ if isinstance(assignment_node, astroid.Comprehension):
438
+ if assignment_node.parent.parent_of(node.scope()):
439
+ self.add_message('cell-var-from-loop', node=node, args=node.name)
440
+ else:
441
+ assign_scope = assignment_node.scope()
442
+ maybe_for = assignment_node
443
+ while not isinstance(maybe_for, astroid.For):
444
+ if maybe_for is assign_scope:
445
+ break
446
+ maybe_for = maybe_for.parent
447
+ else:
448
+ if maybe_for.parent_of(node_scope) and not isinstance(node_scope.statement(), astroid.Return):
449
+ self.add_message('cell-var-from-loop', node=node, args=node.name)
450
+
451
+ def _loopvar_name(self, node, name):
452
+ # filter variables according to node's scope
453
+ # XXX used to filter parents but don't remember why, and removing this
454
+ # fixes a W0631 false positive reported by Paul Hachmann on 2008/12 on
455
+ # python-projects (added to func_use_for_or_listcomp_var test)
456
+ #astmts = [stmt for stmt in node.lookup(name)[1]
457
+ # if hasattr(stmt, 'ass_type')] and
458
+ # not stmt.statement().parent_of(node)]
459
+ if not self.linter.is_message_enabled('undefined-loop-variable'):
460
+ return
461
+ astmts = [stmt for stmt in node.lookup(name)[1]
462
+ if hasattr(stmt, 'ass_type')]
463
+ # filter variables according their respective scope test is_statement
464
+ # and parent to avoid #74747. This is not a total fix, which would
465
+ # introduce a mechanism similar to special attribute lookup in
466
+ # modules. Also, in order to get correct inference in this case, the
467
+ # scope lookup rules would need to be changed to return the initial
468
+ # assignment (which does not exist in code per se) as well as any later
469
+ # modifications.
470
+ if not astmts or (astmts[0].is_statement or astmts[0].parent) \
471
+ and astmts[0].statement().parent_of(node):
472
+ _astmts = []
473
+ else:
474
+ _astmts = astmts[:1]
475
+ for i, stmt in enumerate(astmts[1:]):
476
+ if (astmts[i].statement().parent_of(stmt)
477
+ and not in_for_else_branch(astmts[i].statement(), stmt)):
478
+ continue
479
+ _astmts.append(stmt)
480
+ astmts = _astmts
481
+ if len(astmts) == 1:
482
+ ass = astmts[0].ass_type()
483
+ if isinstance(ass, (astroid.For, astroid.Comprehension, astroid.GenExpr)) \
484
+ and not ass.statement() is node.statement():
485
+ self.add_message('undefined-loop-variable', args=name, node=node)
486
+
487
+ @check_messages('redefine-in-handler')
488
+ def visit_excepthandler(self, node):
489
+ for name in get_all_elements(node.name):
490
+ clobbering, args = clobber_in_except(name)
491
+ if clobbering:
492
+ self.add_message('redefine-in-handler', args=args, node=name)
493
+
494
+ def visit_assname(self, node):
495
+ if isinstance(node.ass_type(), astroid.AugAssign):
496
+ self.visit_name(node)
497
+
498
+ def visit_delname(self, node):
499
+ self.visit_name(node)
500
+
501
+ @check_messages(*(MSGS.keys()))
502
+ def visit_name(self, node):
503
+ """check that a name is defined if the current scope and doesn't
504
+ redefine a built-in
505
+ """
506
+ stmt = node.statement()
507
+ if stmt.fromlineno is None:
508
+ # name node from a astroid built from live code, skip
509
+ assert not stmt.root().file.endswith('.py')
510
+ return
511
+ name = node.name
512
+ frame = stmt.scope()
513
+ # if the name node is used as a function default argument's value or as
514
+ # a decorator, then start from the parent frame of the function instead
515
+ # of the function frame - and thus open an inner class scope
516
+ if (is_func_default(node) or is_func_decorator(node)
517
+ or is_ancestor_name(frame, node)):
518
+ start_index = len(self._to_consume) - 2
519
+ else:
520
+ start_index = len(self._to_consume) - 1
521
+ # iterates through parent scopes, from the inner to the outer
522
+ base_scope_type = self._to_consume[start_index][-1]
523
+ for i in range(start_index, -1, -1):
524
+ to_consume, consumed, scope_type = self._to_consume[i]
525
+ # if the current scope is a class scope but it's not the inner
526
+ # scope, ignore it. This prevents to access this scope instead of
527
+ # the globals one in function members when there are some common
528
+ # names. The only exception is when the starting scope is a
529
+ # comprehension and its direct outer scope is a class
530
+ if scope_type == 'class' and i != start_index and not (
531
+ base_scope_type == 'comprehension' and i == start_index-1):
532
+ # XXX find a way to handle class scope in a smoother way
533
+ continue
534
+ # the name has already been consumed, only check it's not a loop
535
+ # variable used outside the loop
536
+ if name in consumed:
537
+ defnode = assign_parent(consumed[name][0])
538
+ self._check_late_binding_closure(node, defnode, scope_type)
539
+ self._loopvar_name(node, name)
540
+ break
541
+ # mark the name as consumed if it's defined in this scope
542
+ # (i.e. no KeyError is raised by "to_consume[name]")
543
+ try:
544
+ consumed[name] = to_consume[name]
545
+ except KeyError:
546
+ continue
547
+ # checks for use before assignment
548
+ defnode = assign_parent(to_consume[name][0])
549
+ if defnode is not None:
550
+ self._check_late_binding_closure(node, defnode, scope_type)
551
+ defstmt = defnode.statement()
552
+ defframe = defstmt.frame()
553
+ maybee0601 = True
554
+ if not frame is defframe:
555
+ maybee0601 = False
556
+ elif defframe.parent is None:
557
+ # we are at the module level, check the name is not
558
+ # defined in builtins
559
+ if name in defframe.scope_attrs or builtin_lookup(name)[1]:
560
+ maybee0601 = False
561
+ else:
562
+ # we are in a local scope, check the name is not
563
+ # defined in global or builtin scope
564
+ if defframe.root().lookup(name)[1]:
565
+ maybee0601 = False
566
+ else:
567
+ # check if we have a nonlocal
568
+ if name in defframe.locals:
569
+ maybee0601 = not any(isinstance(child, astroid.Nonlocal)
570
+ and name in child.names
571
+ for child in defframe.get_children())
572
+ if (maybee0601
573
+ and stmt.fromlineno <= defstmt.fromlineno
574
+ and not is_defined_before(node)
575
+ and not are_exclusive(stmt, defstmt, ('NameError', 'Exception', 'BaseException'))):
576
+ if defstmt is stmt and isinstance(node, (astroid.DelName,
577
+ astroid.AssName)):
578
+ self.add_message('undefined-variable', args=name, node=node)
579
+ elif self._to_consume[-1][-1] != 'lambda':
580
+ # E0601 may *not* occurs in lambda scope
581
+ self.add_message('used-before-assignment', args=name, node=node)
582
+ if isinstance(node, astroid.AssName): # Aug AssName
583
+ del consumed[name]
584
+ else:
585
+ del to_consume[name]
586
+ # check it's not a loop variable used outside the loop
587
+ self._loopvar_name(node, name)
588
+ break
589
+ else:
590
+ # we have not found the name, if it isn't a builtin, that's an
591
+ # undefined name !
592
+ if not (name in astroid.Module.scope_attrs or is_builtin(name)
593
+ or name in self.config.additional_builtins):
594
+ self.add_message('undefined-variable', args=name, node=node)
595
+
596
+ @check_messages('no-name-in-module')
597
+ def visit_import(self, node):
598
+ """check modules attribute accesses"""
599
+ for name, _ in node.names:
600
+ parts = name.split('.')
601
+ try:
602
+ module = node.infer_name_module(parts[0]).next()
603
+ except astroid.ResolveError:
604
+ continue
605
+ self._check_module_attrs(node, module, parts[1:])
606
+
607
+ @check_messages('no-name-in-module')
608
+ def visit_from(self, node):
609
+ """check modules attribute accesses"""
610
+ name_parts = node.modname.split('.')
611
+ level = getattr(node, 'level', None)
612
+ try:
613
+ module = node.root().import_module(name_parts[0], level=level)
614
+ except AstroidBuildingException:
615
+ return
616
+ except Exception, exc:
617
+ print 'Unhandled exception in VariablesChecker:', exc
618
+ return
619
+ module = self._check_module_attrs(node, module, name_parts[1:])
620
+ if not module:
621
+ return
622
+ for name, _ in node.names:
623
+ if name == '*':
624
+ continue
625
+ self._check_module_attrs(node, module, name.split('.'))
626
+
627
+ @check_messages('unbalanced-tuple-unpacking', 'unpacking-non-sequence')
628
+ def visit_assign(self, node):
629
+ """Check unbalanced tuple unpacking for assignments
630
+ and unpacking non-sequences.
631
+ """
632
+ if not isinstance(node.targets[0], (astroid.Tuple, astroid.List)):
633
+ return
634
+
635
+ targets = node.targets[0].itered()
636
+ try:
637
+ for infered in node.value.infer():
638
+ self._check_unpacking(infered, node, targets)
639
+ except astroid.InferenceError:
640
+ return
641
+
642
+ def _check_unpacking(self, infered, node, targets):
643
+ """ Check for unbalanced tuple unpacking
644
+ and unpacking non sequences.
645
+ """
646
+ if infered is astroid.YES:
647
+ return
648
+ if isinstance(infered, (astroid.Tuple, astroid.List)):
649
+ # attempt to check unpacking is properly balanced
650
+ values = infered.itered()
651
+ if len(targets) != len(values):
652
+ self.add_message('unbalanced-tuple-unpacking', node=node,
653
+ args=(_get_unpacking_extra_info(node, infered),
654
+ len(targets),
655
+ len(values)))
656
+ # attempt to check unpacking may be possible (ie RHS is iterable)
657
+ elif isinstance(infered, astroid.Instance):
658
+ for meth in ('__iter__', '__getitem__'):
659
+ try:
660
+ infered.getattr(meth)
661
+ break
662
+ except astroid.NotFoundError:
663
+ continue
664
+ else:
665
+ self.add_message('unpacking-non-sequence', node=node,
666
+ args=(_get_unpacking_extra_info(node, infered),))
667
+ else:
668
+ self.add_message('unpacking-non-sequence', node=node,
669
+ args=(_get_unpacking_extra_info(node, infered),))
670
+
671
+
672
+ def _check_module_attrs(self, node, module, module_names):
673
+ """check that module_names (list of string) are accessible through the
674
+ given module
675
+ if the latest access name corresponds to a module, return it
676
+ """
677
+ assert isinstance(module, astroid.Module), module
678
+ while module_names:
679
+ name = module_names.pop(0)
680
+ if name == '__dict__':
681
+ module = None
682
+ break
683
+ try:
684
+ module = module.getattr(name)[0].infer().next()
685
+ if module is astroid.YES:
686
+ return None
687
+ except astroid.NotFoundError:
688
+ self.add_message('no-name-in-module', args=(name, module.name), node=node)
689
+ return None
690
+ except astroid.InferenceError:
691
+ return None
692
+ if module_names:
693
+ # FIXME: other message if name is not the latest part of
694
+ # module_names ?
695
+ modname = module and module.name or '__dict__'
696
+ self.add_message('no-name-in-module', node=node,
697
+ args=('.'.join(module_names), modname))
698
+ return None
699
+ if isinstance(module, astroid.Module):
700
+ return module
701
+ return None
702
+
703
+
704
+ class VariablesChecker3k(VariablesChecker):
705
+ '''Modified variables checker for 3k'''
706
+ # listcomp have now also their scope
707
+
708
+ def visit_listcomp(self, node):
709
+ """visit dictcomp: update consumption analysis variable
710
+ """
711
+ self._to_consume.append((copy(node.locals), {}, 'comprehension'))
712
+
713
+ def leave_listcomp(self, _):
714
+ """leave dictcomp: update consumption analysis variable
715
+ """
716
+ # do not check for not used locals here
717
+ self._to_consume.pop()
718
+
719
+ def leave_module(self, node):
720
+ """ Update consumption analysis variable
721
+ for metaclasses.
722
+ """
723
+ for klass in node.nodes_of_class(astroid.Class):
724
+ if klass._metaclass:
725
+ metaclass = klass.metaclass()
726
+ module_locals = self._to_consume[0][0]
727
+
728
+ if isinstance(klass._metaclass, astroid.Name):
729
+ module_locals.pop(klass._metaclass.name, None)
730
+ if metaclass:
731
+ # if it uses a `metaclass=module.Class`
732
+ module_locals.pop(metaclass.root().name, None)
733
+ super(VariablesChecker3k, self).leave_module(node)
734
+
735
+ if sys.version_info >= (3, 0):
736
+ VariablesChecker = VariablesChecker3k
737
+
738
+
739
+ def register(linter):
740
+ """required method to auto register this checker"""
741
+ linter.register_checker(VariablesChecker(linter))