rubocop-hq/rubocop

RuboCop is a Ruby static code analyzer (a.k.a. linter) and code formatter. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide. Apart from reporting the problems discovered in your code, RuboCop can also automatically fix many of them for you.

RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various configuration options.

Please consider financially supporting its ongoing development.

Installation
RuboCop’s installation is pretty standard:

$ gem install rubocop
If you’d rather install RuboCop using bundler, add a line for it in your Gemfile (but set the require option to false, as it is a standalone tool):

gem ‘rubocop’, require: false
RuboCop’s development is moving at a very rapid pace and there are often backward-incompatible changes between minor releases (since we haven’t reached version 1.0 yet). To prevent an unwanted RuboCop update you might want to use a conservative version lock in your Gemfile:

gem ‘rubocop’, ‘~> 0.91.0’, require: false
Quickstart
Just type rubocop in a Ruby project’s folder and watch the magic happen.

$ cd my/cool/ruby/project
$ rubocop
Documentation
You can read a lot more about RuboCop in its official docs.

Compatibility
RuboCop supports the following Ruby implementations:

MRI 2.4+
JRuby 9.2+
See compatibility for further details.

Readme Badge
If you use RuboCop in your project, you can include one of these badges in your readme to let people know that your code is written following the community Ruby Style Guide.

Ruby Style Guide

Ruby Style Guide

Team
Here’s a list of RuboCop’s core developers:

Bozhidar Batsov (author & head maintainer)
Jonas Arvidsson
Yuji Nakayama (retired)
Evgeni Dzhelyov (retired)
Ted Johansson
Masataka Kuwabara
Koichi Ito
Maxim Krizhanovski
Benjamin Quorning
Marc-André Lafortune
Logo
RuboCop’s logo was created by Dimiter Petrov. You can find the logo in various formats here.

The logo is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Contributors
Here’s a list of all the people who have contributed to the development of RuboCop.

I’m extremely grateful to each and every one of them!

If you’d like to contribute to RuboCop, please take the time to go through our short contribution guidelines.

Converting more of the Ruby Style Guide into RuboCop cops is our top priority right now. Writing a new cop is a great way to dive into RuboCop!

Of course, bug reports and suggestions for improvements are always welcome. GitHub pull requests are even better! 😃

Funding
While RuboCop is free software and will always be, the project would benefit immensely from some funding. Raising a monthly budget of a couple of thousand dollars would make it possible to pay people to work on certain complex features, fund other development related stuff (e.g. hardware, conference trips) and so on. Raising a monthly budget of over $5000 would open the possibility of someone working full-time on the project which would speed up the pace of development significantly.

We welcome both individual and corporate sponsors! We also offer a wide array of funding channels to account for your preferences (although currently Open Collective is our preferred funding platform).

If you’re working in a company that’s making significant use of RuboCop we’d appreciate it if you suggest to your company to become a RuboCop sponsor.

You can support the development of RuboCop via GitHub Sponsors, Patreon, PayPal and Open Collective.

Open Collective Backers
Support us with a monthly donation and help us continue our activities. [Become a backer]

Open Collective Sponsors
Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]

Changelog
RuboCop’s changelog is available here.

Copyright
Copyright © 2012-2020 Bozhidar Batsov. See LICENSE.txt for further details.

你已经成功编译了 Mosquitto 源码,但还**没有安装**它,因此系统无法找到 `mosquitto` 命令。你看到的提示: ``` Command 'mosquitto' not found, but can be installed with: sudo apt install mosquitto ``` 是 Ubuntu 的 `command-not-found` 机制建议你从官方仓库安装 Mosquitto,但这并不是你当前自己编译的版本。 --- ### 回答问题: **为什么执行 `mosquitto` 提示命令未找到?** ### 解释原因: 虽然你成功运行了 `make` 编译了源码(进入 src 和 man 目录),但以下关键步骤尚未完成: 1. **未运行 `make install`**:编译后的可执行文件(如 `mosquitto`, `mosquitto_sub`, `mosquitto_pub`)只存在于 `client/` 和 `src/` 目录下,并未复制到系统路径(如 `/usr/local/bin`)。 2. **未将编译生成的二进制文件加入 PATH**:即使有可执行文件,如果不加路径直接运行 `mosquitto`,shell 不知道去哪里找它。 3. **可能缺少配置文件和用户权限设置**:Mosquitto 守护进程需要配置文件、日志目录、专用用户等才能正常运行。 --- ### 解决方法: #### ✅ 步骤 1:确认编译生成的可执行文件是否存在 ```bash ls -l client/mosquitto_sub src/mosquitto ``` 你应该能看到类似: ``` -rwxr-xr-x 1 hq hq ... src/mosquitto # 这就是 broker 可执行文件 -rwxr-xr-x 1 hq hq ... client/mosquitto_sub -rwxr-xr-x 1 hq hq ... client/mosquitto_pub ``` #### ✅ 步骤 2:安装到系统(推荐使用默认前缀 /usr/local) 如果你在编译前没有修改 `config.mk`,默认安装路径为 `/usr/local`。 运行安装命令: ```bash sudo make install ``` > 注意:你需要先 `make` 成功后再 `make install`。 这个命令会把: - `src/mosquitto` → `/usr/local/sbin/mosquitto` - `client/mosquitto_*` → `/usr/local/bin/` - 配置文件、man 手册等也一并安装 #### ✅ 步骤 3:确保 `/usr/local/sbin` 在你的 `PATH` 中 普通用户可能看不到 `/usr/local/sbin`,你可以检查: ```bash echo $PATH | grep /usr/local/sbin ``` 如果没有,临时添加: ```bash export PATH=/usr/local/sbin:/usr/local/bin:$PATH ``` 然后测试: ```bash mosquitto -h ``` 应该能显示帮助信息。 #### ✅ 步骤 4:准备配置文件并启动服务 创建最小配置文件 `mosquitto.conf`: ```bash echo "listener 1883" > ~/mosquitto.conf echo "persistence false" >> ~/mosquitto.conf echo "log_dest stdout" >> ~/mosquitto.conf ``` 启动 Mosquitto Broker: ```bash mosquitto -c ~/mosquitto.conf ``` 你应该看到输出: ``` Starting in local only mode. Connect locally via loopback interface. Bind address not specified, binding to all interfaces. ... ``` 说明服务已启动,监听 1883 端口。 --- ### 补充说明(C语言项目常见流程): 对于从源码编译的 C 项目(如 Mosquitto),典型流程如下: ```bash ./configure # 或手动编辑 config.mk(Mosquitto 使用 Makefile) make # 编译生成二进制文件 sudo make install # 安装到系统目录 ``` 有些项目还需要: - `sudo ldconfig` 更新动态库缓存 - 创建用户:`sudo useradd -r mosquitto` - 手动复制配置文件到 `/etc/mosquitto/` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值