如何检查整个 rails 项目的编译错误 [英] How to check entire rails project for compilation errors

查看:46
本文介绍了如何检查整个 rails 项目的编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 ruby​​ 和 rails 的新手.我习惯于在 IDE(Xcode、Visual Studio 等)中工作,在那里我可以执行项目范围/工作区范围的构建/编译"操作.

I am new to ruby and rails. I am used to working in IDEs (Xcode, Visual Studio, etc.) where I can perform project-wide/workspace-wide "build/compile" operations.

假设我修改了 Rails 项目中的一些 ruby​​ 文件.我还没有编写测试来执行我的所有更改.

Let's say that I modify a number of ruby files in my rails project. I haven't yet written tests that will exercise all of my changes.

有没有办法确保我的所有 *.rb 文件在不直接在运行时运行的情况下编译?我真的只想执行编译我所有的 ruby​​/erb 文件"操作,以便我知道我目前没有任何语法错误.

Is there a way to ensure that all of my *.rb files compile without directly exercising them at runtime? I'd really just like to perform a "compile all of my ruby/erb files" operation so that I know that I don't currently have any syntax errors.

更新

我可能应该提到我已经专业地编写代码 20 年了.我意识到 Ruby 不像 C++ 那样编译,但这并不意味着它的语法不能被检查.就我而言,我决定使用 ruby-lint 来捕获基本的语法错误,而不必在运行时练习代码.

I probably should have mentioned that I've been writing code professionally for 20 years. I realize that Ruby isn't compiled like, say, C++, but that doesn't mean that its syntax can't be checked. In my case, I've decided to use ruby-lint to catch basic syntax errors without having to exercise the code at runtime.

推荐答案

Ruby 是一种解释型语言.没有编译步骤.在编写代码之前,请遵循 TDD 并编写测试.

Ruby is an interpreted language. There is no compilation step. Please follow TDD and write your tests before you write your code.

更新:由于此答案已被接受,除非 OP 接受另一个答案,否则我无法删除它,但人们通过 Google 搜索登陆此处,请参阅其他答案.这与其说是回答,不如说是口齿伶俐.Ruby 社区有很棒的工具可以像 Rubocop 和朋友一样进行各种静态代码分析.至少,ruby -c 将完成 OP 想要的.

UPDATE: Since this answer was accepted, I can't delete it unless the OP accepts another answer but people landing here through Google search, please see the other answers. This was more of a tongue in cheek remark than an answer. Ruby community has wonderful tools for doing all kinds of static code analysis like Rubocop and friends. At the bare minimum, ruby -c will accomplish what the OP wanted.

这篇关于如何检查整个 rails 项目的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆