---
title: "install metric_fu"
author: "chengyuanheng"
date: "2014-12-04T11:15:08Z"
tags: []
categories: ["编程语言"]
slug: "install-metric-fu"
draft: false
lastmod: "2014-12-04T11:15:08Z"
id: 2163115
url: "https://cckkll.iteye.com/blog/2163115"
---

**metric\_fu**

## [](https://github.com/chengyuanheng/FinanceStar#installation)Installation

```
gem install metric_fu
```

## [](https://github.com/chengyuanheng/FinanceStar#gem)Gem

From your Gemfile ,install these gems for test and development environment

```
group :test ,:development do

gem "metric_fu"

gem 'simplecov'

gem 'simplecov-rcov-text'

gem 'roodi' #these gem ensure that you can run roodi or roodi . in shell

end
```

## [](https://github.com/chengyuanheng/FinanceStar#require)Require

From your Rakefile

```
 require 'churn'
```

## [](https://github.com/chengyuanheng/FinanceStar#usage)Usage

From your application root. Running via Rake is still supported.

```
metric_fu
```

See:

- `metric_fu --help` for more options

## [](https://github.com/chengyuanheng/FinanceStar#run)Run

run "rake -T", you can see all of Commands that you can use , for example:

```
rake metrics:all 
rake metrics:cane
rake metrics:churn
rake metrics:flay
rake metrics:flog
rake metrics:hotspots
rake metrics:only
rake metrics:rails_best_practices
rake metrics:reek
rake metrics:roodi
rake metrics:saikuro
rake metrics:stats 
```

Run these commands , you will get some reports at "server/tmp/metric\_fu/output" and yml files at "server/tmp/metric\_fu/\_data"

## [](https://github.com/chengyuanheng/FinanceStar#in-shell)In shell

```
rspec .
```

Run the command , you will run all testings include all of engine and get a value about test coverage

 

run other metric\_fu features: 

```
flog feature/ #measuring code complexity
```

```
flay feature/ #find duplicate (including copy / paste and structure)
```

```
reek .   or   reek features/     #spot code smells
```

```
roodi  or  roodi .          #find a large number of general issues
```

```
rake churn     #Identifies the file changes too frequently
```

```
rails_best_practices .      #code matrix tool
```

```
cane             #code quality threshold violation
```

Extra

    saikuro - cyclomatic complexity measure

    hotspot - hot code analysis

## [](https://github.com/chengyuanheng/FinanceStar#link)Link

**metric\_fu :** [https://github.com/metricfu/metric\_fu](https://github.com/metricfu/metric_fu)

 

**reek, a code smells detector for ruby :** [http://silkandspinach.net/2008/09/23/reek-a-code-smells-detector-for-ruby/](http://silkandspinach.net/2008/09/23/reek-a-code-smells-detector-for-ruby/)

 

**How To Score Your Rails App's Complexity Before Refactoring :** [http://www.railsinside.com/tutorials/487-how-to-score-your-rails-apps-complexity-before-refactoring.html](http://www.railsinside.com/tutorials/487-how-to-score-your-rails-apps-complexity-before-refactoring.html)