专属域名
文档搜索
轩辕助手
Run助手
邀请有礼
返回顶部
快速返回页面顶部
收起
收起工具栏
轩辕镜像 官方专业版
轩辕镜像 官方专业版轩辕镜像 官方专业版官方专业版
首页个人中心搜索镜像

交易
充值流量我的订单
工具
提交工单镜像收录一键安装
Npm 源Pip 源Homebrew 源
帮助
常见问题
其他
关于我们网站地图

官方QQ群: 1072982923

conchoid/unused Docker 镜像 - 轩辕镜像 | Docker 镜像高效稳定拉取服务

热门搜索:openclaw🔥nginx🔥redis🔥mysqlopenjdkcursorweb2apimemgraphzabbixetcdubuntucorednsjdk
unused
conchoid/unused
自动构建
conchoid
docker images for unused
下载次数: 0状态:自动构建维护者:conchoid仓库类型:镜像最近更新:1 个月前
轩辕镜像,让镜像更快,让人生更轻。点击查看
镜像简介版本下载
轩辕镜像,让镜像更快,让人生更轻。点击查看

Unused ![Build Status]([***]

A command line tool to identify unused code.

!Image of Unused Output

"What kinds of projects can I used it on?"

Anything.

Yes, literally anything.

It's probably best if you have a file generated from ctags it can read from (it looks in .git, tmp, and the root directory for a tags file), but if you have another way to pipe a bunch of methods/functions/classes/modules/whatever in, that works too.

Right now, there are some special cases built in for Rails and Phoenix apps (specifically, assumptions about what's fine to only have one reference to, e.g. Controllers in Rails and Views in Phoenix), but it'll work on Rubygems, Elixir packages, or anything else.

That said, be confident the code you're removing won't break your program. Especially with projects built in Ruby, Elixir, or JavaScript, there are ways to dynamically trigger or define behavior that may be surprising. A test suite can help here, but still cannot determine every possible execution path.

Installing and Updating

Homebrew (Recommended)

You can install my formulae via Homebrew with brew tap:

sh
brew tap joshuaclayton/formulae

Next, run:

sh
brew install unused

This will install unused and its corresponding dependencies.

To update, run:

sh
brew update
brew upgrade unused

Alternatively, you can install with Stack or by hand. Because it needs to compile, installation times may vary, but it's often several minutes.

Stack

If you already have Stack installed, ensure you have the latest list of packages:

sh
stack update

Verify Stack is using at least lts-6.0 when installing by checking the global project settings in ~/.stack/global-project/stack.yaml.

Once that is complete, run:

sh
stack install unused

This will install unused in the appropriate directory for Stack; you'll want to ensure your $PATH reflects this.

Installing by hand

This project is written in Haskell and uses Stack.

Once you have these tools installed and the project cloned locally:

sh
stack setup
stack install

This will generate a binary in $HOME/.local/bin; ensure this directory is in your $PATH.

Install via Docker

Once Docker is installed, create a binary within your $PATH to run the image:

bash
#!/usr/bin/env bash

docker run --rm -it -v $(pwd):/code joshuaclayton/unused unused $@

Note that, because Unused will be running inside of a virtual machine, it will take longer to generate output than were you to install via previously-mentioned methods.

Using Unused

unused attempts to read from common tags file locations (.git/tags, tags, and tmp/tags).

In an application where the tags file exists, run:

sh
unused

If you don't have a tags file, you can generate one by running:

sh
git ls-files | xargs ctags

If you want to specify a custom tags file, or load tokens from somewhere else, run:

sh
cat .custom/tags | unused --stdin

To view more usage options, run:

sh
unused --help

Troubleshooting

Ctags (and a corresponding workflow) isn't configured

Exuberant Ctags (or another tool that will generate a tags file, like hasktags for Haskell projects) is required to use unused correctly; however, the version of ctags that ships with OS X (/usr/bin/ctags) is an older version won't work with many languages (that BSD version of ctags says it "makes a tags file for ex(1) from the specified C, Pascal, Fortran, YACC, lex, and lisp sources.")

Installation via Homebrew includes the ctags dependency. You can also run brew install ctags by hand. If you're not on OS X, use your favorite package manager and refer to the Exuberant Ctags site for download instructions.

Ctags manual run

If you're using ctags to generate a tags file prior to running unused and don't have a workflow around automatically generating a tags file, run:

sh
git ls-files | xargs ctags -f tmp/tags

This will take your .gitignore into account and write the tags file to tmp/tags. Be sure to write this to a location that's ignored by git.

While this process allows a developer to get started, it requires remembering to run this command before running unused. Let's explore how to automate this process.

Ctags automatic runs via git hooks

With ctags installed, you'll likely want to configure your workflow such that your tags file gets updated periodically without any action on your part. I recommend following the instructions outlined by Tim Pope on this matter, which discusses a workflow coupled to git for managing the tags file. It includes shell scripting that may not look "effortless"; however, the fact this is automated helps to ensure unused is running against new versions of the code as you (and other teammates, if you have any) are committing.

As he suggests, you'll want to run git init into the directories you want this hook, and to manually run the hook:

sh
git ctags

unused is configured to look for a tags file in three different directories, including .git/ as the article suggests, so no further configuration will be necessary with unused.

"Calculating cache fingerprint" takes a long time

unused attempts to be intelligent at understanding if your codebase has changed before running analysis (since it can be time-consuming on large codebases). To do so, it calculates a "fingerprint" of the entire directory by using md5 (or md5sum), along with find and your .gitignore file.

If you're checking in artifacts (e.g. node_modules/, dist/, tmp/, or similar), unused will likely take significantly longer to calculate the fingerprint.

Per the --help documentation, you can disable caching with the -C flag:

sh
$ unused -C
"No results found" when expecting results

If you're expecting to see results but unused doesn't find anything, verify that any artifacts unused uses (e.g. the tags file, wherever it's located) or generates (e.g. in PROJECT_ROOT/tmp/unused) is .gitignored.

What might be happening is, because unused searches for tokens with ag (which honors .gitignore), it's running into checked-in versions of the tokens from other files, resulting in duplicate occurrences that aren't representative of the actual codebase. The most obvious might be the tags file itself, although if you're using an IDE that runs any sort of analysis and that's getting checked in somehow, that may cause it too.

One final piece to check is the number of tokens in the tags file itself; if ctags is misconfigured and only a handful of tokens are being analyzed, they all may have low removal likelihood and not display in the default results (high-likelihood only).

Analysis takes a long time due to a large number of terms found

In my experience, projects under 100,000LOC should have at most around 8,000 unique tokens found. This obviously depends on how you structure your classes/modules/functions, but it'll likely be close.

If you're seeing more than 15,000 terms matched (I've seen upwards of 70,000), this is very likely due to misconfiguration of ctags where it includes some amount of build artifacts. In Ruby, this might be a RAILS_ROOT/vendor directory, or if you're using NPM, APP_ROOT/node_modules or APP_ROOT/bower_components.

When configuring ctags, be sure to include your --exclude directives; you can find an example here.

Custom Configuration

The first time you use unused, you might see a handful of false positives. unused will look in two additional locations in an attempt to load additional custom configuration to help improve this.

Configuration format
yaml
# Language or framework name
#   e.g. Rails, Ruby, Go, Play
- name: Framework or language
  # Collection of matches allowed to have one occurrence
  autoLowLikelihood:
    # Low likelihood match name
    - name: ActiveModel::Serializer
      # Flag to capture only capitalized names
      #   e.g. would match `ApplicationController`, not `with_comments`
      classOrModule: true

      # Matcher for `.*Serializer$`
      #   e.g. `UserSerializer`, `ProjectSerializer`
      termEndsWith: Serializer

      # Matcher for `^with_.*`
      #   e.g. `with_comments`, `with_previous_payments`
      termStartsWith: with_

      # Matcher for `^ApplicationController$`
      termEquals: ApplicationController

      # Matcher for `.*_factory.ex`
      #   e.g. `lib/appname/user_factory.ex`, `lib/appname/project_factory.ex`
      pathEndsWith: _factory.ex

      # Matcher for `^app/policies.*`
      #   e.g. `app/policies/user_policy.rb`, `app/policies/project_policy.rb`
      pathStartsWith: app/policies

      # list of termEquals
      # Matcher allowing any exact match from a list
      allowedTerms:
      - index?
      - edit?
      - create?
~/.unused.yml

The first location is ~/.unused.yml. This should hold widely-used configuration roughly applicable across projects. Here's an example of what might be present:

yaml
- name: Rails
  autoLowLikelihood:
    - name: ActiveModel::Serializer
      termEndsWith: Serializer
      classOrModule: true
    - name: Pundit
      termEndsWith: Policy
      classOrModule: true
      pathEndsWith: .rb
    - name: Pundit Helpers
      allowedTerms:
        - Scope
        - index?
        - new?
        - create?
        - show?
        - edit?
        - destroy?
        - resolve
    - name: JSONAPI::Resources
      termEndsWith: Resource
      classOrModule: true
      pathStartsWith: app/resources
    - name: JSONAPI::Resources Helpers
      allowedTerms:
      - updatable_fields
      pathStartsWith: app/resources

I tend to work on different APIs, and the two libraries I most commonly use have a fairly similar pattern when it comes to class naming. They both also use that naming structure to identify serializers automatically, meaning they very well may only be referenced once in the entire application (when they're initially defined).

Similarly, with Pundit, an authorization library, naming conventions often mean only one reference to the class name.

This is a file that might grow, but is focused on widely-used patterns across codebases. You might even want to check it into your dotfiles.

APP_ROOT/.unused.yml

The second location is APP_ROOT/.unused.yml. This is where any project-specific settings might live. If you're working on a library before extracting to a gem or package, you might have this configuration take that into account.

Validation

unused will attempt to parse both of these files, if it finds them. If either is invalid either due to missing or mistyped keys, an error will be displayed.

Requirements

Unused leverages Ag to analyze the codebase; as such, you'll need to have ag available in your $PATH. This is set as an explicit dependency in Homebrew.

Alternatively, if you'd like to use RipGrep, you can do so with the --search rg flag. Be sure to have RipGrep installed first.

Testing

To run the test suite, run:

sh
stack test

License

Copyright 2016-2018 Josh Clayton. See the LICENSE.

查看更多 unused 相关镜像 →
conchoid/fuzz logo
conchoid/fuzz
conchoid
暂无描述
5万+ 次下载
6 个月前更新
conchoid/docker-pyenv logo
conchoid/docker-pyenv
conchoid
用于在Docker容器中安装pyenv的Docker镜像,支持在容器环境中便捷管理多个Python版本。
5万+ 次下载
2 个月前更新
conchoid/docker-nodenv logo
conchoid/docker-nodenv
conchoid
用于在Docker容器中安装和使用nodenv的镜像,提供预构建版本,方便在容器环境中管理Node.js版本,预构建镜像可从Docker Hub获取。
1万+ 次下载
1 个月前更新
conchoid/docker-rbenv logo
conchoid/docker-rbenv
conchoid
用于在Docker容器中安装rbenv的镜像,预构建版本可从Docker Hub获取,帮助在容器环境中便捷使用rbenv进行Ruby版本管理。
1万+ 次下载
2 个月前更新
conchoid/ml logo
conchoid/ml
conchoid
暂无描述
1万+ 次下载
9 个月前更新
conchoid/docker-phpenv logo
conchoid/docker-phpenv
conchoid
用于在Docker容器中安装madumlao/phpenv的Docker镜像,提供预构建版本,便于在容器环境中管理PHP版本。
1万+ 次下载
1 个月前更新

轩辕镜像配置手册

探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式

Docker 配置

登录仓库拉取

通过 Docker 登录认证访问私有仓库

专属域名拉取

无需登录使用专属域名

K8s Containerd

Kubernetes 集群配置 Containerd

K3s

K3s 轻量级 Kubernetes 镜像加速

Dev Containers

VS Code Dev Containers 配置

Podman

Podman 容器引擎配置

Singularity/Apptainer

HPC 科学计算容器配置

其他仓库配置

ghcr、Quay、nvcr 等镜像仓库

Harbor 镜像源配置

Harbor Proxy Repository 对接专属域名

Portainer 镜像源配置

Portainer Registries 加速拉取

Nexus 镜像源配置

Nexus3 Docker Proxy 内网缓存

系统配置

Linux

在 Linux 系统配置镜像服务

Windows/Mac

在 Docker Desktop 配置镜像

MacOS OrbStack

MacOS OrbStack 容器配置

Docker Compose

Docker Compose 项目配置

NAS 设备

群晖

Synology 群晖 NAS 配置

飞牛

飞牛 fnOS 系统配置镜像

绿联

绿联 NAS 系统配置镜像

威联通

QNAP 威联通 NAS 配置

极空间

极空间 NAS 系统配置服务

网络设备

爱快路由

爱快 iKuai 路由系统配置

宝塔面板

在宝塔面板一键配置镜像

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

使用与功能问题

配置了专属域名后,docker search 为什么会报错?

docker search 限制

Docker Hub 上有的镜像,为什么在轩辕镜像网站搜不到?

站内搜不到镜像

机器不能直连外网时,怎么用 docker save / load 迁镜像?

离线 save/load

docker pull 拉插件报错(plugin v1+json)怎么办?

插件要用 plugin install

WSL 里 Docker 拉镜像特别慢,怎么排查和优化?

WSL 拉取慢

轩辕镜像安全吗?如何用 digest 校验镜像没被篡改?

安全与 digest

第一次用轩辕镜像拉 Docker 镜像,要怎么登录和配置?

新手拉取配置

错误码与失败问题

docker pull 提示 manifest unknown 怎么办?

manifest unknown

docker pull 提示 no matching manifest 怎么办?

no matching manifest(架构)

Docker pull 时 HTTPS / TLS 证书验证失败怎么办?

TLS 证书失败

Docker pull 时 DNS 解析超时或连不上仓库怎么办?

DNS 超时

Docker 拉取出现 410 Gone 怎么办?

410 Gone 排查

出现 402 或「流量用尽」提示怎么办?

402 与流量用尽

Docker 拉取提示 UNAUTHORIZED(401)怎么办?

401 认证失败

遇到 429 Too Many Requests(请求太频繁)怎么办?

429 限流

docker login 提示 Cannot autolaunch D-Bus,还算登录成功吗?

D-Bus 凭证提示

为什么会出现「单层超过 20GB」或 413,无法加速拉取?

413 与超大单层

账号 / 计费 / 权限

轩辕镜像免费版和专业版有什么区别?

免费版与专业版区别

轩辕镜像支持哪些 Docker 镜像仓库?

支持的镜像仓库

镜像拉取失败还会不会扣流量?

失败是否计费

麒麟 V10 / 统信 UOS 提示 KYSEC 权限不够怎么办?

KYSEC 拦截脚本

如何在轩辕镜像申请开具发票?

申请开票

怎么修改轩辕镜像的网站登录和仓库登录密码?

修改登录密码

如何注销轩辕镜像账户?要注意什么?

注销账户

配置与原理类

写了 registry-mirrors,为什么还是走官方或仍然报错?

mirrors 不生效

怎么用 docker tag 去掉镜像名里的轩辕域名前缀?

去掉域名前缀

如何拉取指定 CPU 架构的镜像(如 ARM64、AMD64)?

指定架构拉取

用轩辕镜像拉镜像时快时慢,常见原因有哪些?

拉取速度原因

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
conchoid/unused
博客公告Docker 镜像公告与技术博客
热门镜像查看热门 Docker 镜像推荐
一键安装一键安装 Docker 并配置镜像源
镜像拉取问题咨询请 提交工单,官方技术交流群:1072982923。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
镜像拉取问题咨询请提交工单,官方技术交流群:。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
商务合作:点击复制邮箱
©2024-2026 源码跳动
商务合作:点击复制邮箱Copyright © 2024-2026 杭州源码跳动科技有限公司. All rights reserved.