脚本语言的代码验证工具
我花了大约两个小时试图理解为什么当我查看页面源代码时,我在 Facebook 应用程序中包含的 JavaScript 文件没有显示。然后猜猜问题出在哪里?我忘记添加语句的最后一个右括号,并且当 Facebook 在添加脚本之前处理脚本(以避免 Facebook 平台出现意外错误)时,它没有附加此脚本,因为它有语法错误!也就是说,由于缺少括号,所以没有添加整个 JavaScript!
因此,为了将来节省时间,我想为我正在使用的脚本语言获取一些语法验证工具:PHP、Python、JavaScript、MySQL(尽管不是真正的脚本语言)。有人可以帮我吗?如果它们是 Vim 插件那就太好了,因为我经常使用它。
请随意分享其他编程语言的验证工具,我不想只为我保留这篇文章。
I spent some two hours trying to understand why the JavaScript file I am including in my Facebook application is not showing when I view the source of my page. Then guess what the problem turned out to be? I forget to add the final closing bracket of a statement, and as Facebook processes the scripts before adding them (to avoid having unexpected errors in Facebook platform), it didn't attach this script because it has a syntax error!! That is, a whole JavaScript was not added because of a missing bracket!
So to save my time in the future I want to get some syntax validation tools for the scripting languages I am using: PHP, Python, JavaScript, MySQL (although not really a scripting language). Can anybody help me with that? It would be great if they are Vim plugins as I use it heavily.
Feel free to share validation tools for other programming languages, I don't want to keep this post for me only.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它带有
VIM
标记,因此我建议查看 jslint.vim 。我将它(对 Windows XP 进行了一些修复)与 VIM 7.3 一起使用。
其他不错的(并且在 Windows 上更容易设置)工具是 syntastic.vim。根据文档,它适用于
eruby
、haml
、html
、javascript
、php
、python
、ruby
和sass
。It's tagged with
VIM
so I would suggeest to look at jslint.vim.I use it (with a few fixes for Windows XP) with VIM 7.3.
Other nice (and much easier to setup on Windows) tool is syntastic.vim. According to documentation it works for
eruby
,haml
,html
,javascript
,php
,python
,ruby
andsass
.查看 http://www.yaldex.com/Free_JavaScript_Editor.htm
他们的界面非常好,但仅限于 Javascript。
我过去曾使用过 Notepad++,它可以很好地突出显示语法,但缺乏您通常在 IDE 中期望的其他功能。
Have a look at the JS Editor available from http://www.yaldex.com/Free_JavaScript_Editor.htm
Their interface is really nice but restricted to Javascript only.
I have used Notepad++ in the past which highlights syntax sufficiently well but lacks other features you'd normally expect in an IDE.
JavaScript: JSLint
Python: PyLint,PyChecker,PyFlakes
PHP:是否有针对 PHP 文件的静态代码分析器 [如 Lint]?
使用 scrip^H^H^H^H 动态语言,我建议仔细配置各种类似 lint 的工具,因为编程风格和项目的要求决定了不同的需求,什么应该被禁止或不应该被禁止。
例如,除了少数情况外,您可能希望避免在 Python 中使用“import *”。或者 eval() 除非你真的知道你在做什么,等等。
有几个 VIM 插件 到 集成这些工具。
Javascript: JSLint
Python: PyLint, PyChecker, PyFlakes
PHP: Is there a static code analyzer [like Lint] for PHP files?
With scrip^H^H^H^Hdynamic languages, i advise to carefully configure the various lint-like tools, because the style of programming and requirements of the project dictate different needs as for what should be forbidden or not.
For instance, you might want to avoid 'import *' in Python, except in a few cases. Or eval() except you really know what you are doing, etc.
There are several VIM plugins to integrate these tools.