Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Pre-commit hook: check for structural similarities with flay #585

Merged
merged 5 commits into from
Jul 17, 2018

Conversation

diegojromerolopez
Copy link
Contributor

New Feature: Pre-commit hook: check for structural similarities with flay

Introduction

This pre-commit hook forces the developers to avoid repeating code. More abou information about Flay here

Requirements

flay

Configuration

Default configuration for this hook

The options for this hook are the flay options: mass threshold, fuzzy and liberal.

   Flay:
    enabled: false
    description: 'Analyze ruby code for structural similarities with Flay'
    required_executable: 'flay'
    install_command: 'gem install flay'
    mass_threshold: 16
    fuzzy: 1
    liberal: false
    include: '**/*.rb'

Example configuration for this hook

    Flay:
      enabled: true
      include:
        - '/app/controllers/*.rb'
        - '/app/facades/*.rb'
        - '/app/libs/*.rb'
        - '/app/models/*.rb'
        - '/app/presenters/*.rb'

Tests

RSpec tests that check the following conditions:

  • Structural similarities found.
  • No structural similarities found.

@diegojromerolopez
Copy link
Contributor Author

AppVeyor raises this error but I'm not sure if it's related to my changes...

Check for broken symlinks............................[BrokenSymlinks] FAILED
Hook raised unexpected error
The parameter is incorrect. (87)
C:/projects/overcommit/vendor/bundle/ruby/2.3.0/gems/childprocess-0.9.0/lib/childprocess/windows/handle.rb:12:in `open'
C:/projects/overcommit/vendor/bundle/ruby/2.3.0/gems/childprocess-0.9.0/lib/childprocess/windows/process.rb:71:in `launch_process'
C:/projects/overcommit/vendor/bundle/ruby/2.3.0/gems/childprocess-0.9.0/lib/childprocess/abstract_process.rb:81:in `start'
C:/projects/overcommit/lib/overcommit/subprocess.rb:35:in `spawn'
C:/projects/overcommit/lib/overcommit/utils/file_utils.rb:49:in `win32_dir_cmd'
C:/projects/overcommit/lib/overcommit/utils/file_utils.rb:24:in `symlink?'
C:/projects/overcommit/lib/overcommit/utils.rb:264:in `broken_symlink?'
C:/projects/overcommit/lib/overcommit/hook/pre_commit/broken_symlinks.rb:6:in `block in run'
C:/projects/overcommit/lib/overcommit/hook/pre_commit/broken_symlinks.rb:6:in `select'
C:/projects/overcommit/lib/overcommit/hook/pre_commit/broken_symlinks.rb:6:in `run'
C:/projects/overcommit/lib/overcommit/hook/base.rb:45:in `block in run_and_transform'
C:/projects/overcommit/lib/overcommit/utils.rb:253:in `with_environment'
C:/projects/overcommit/lib/overcommit/hook/base.rb:45:in `run_and_transform'
C:/projects/overcommit/lib/overcommit/hook_runner.rb:162:in `run_hook'
C:/projects/overcommit/lib/overcommit/hook_runner.rb:95:in `block in consume'
C:/projects/overcommit/lib/overcommit/hook_runner.rb:92:in `loop'
C:/projects/overcommit/lib/overcommit/hook_runner.rb:92:in `consume'
Analyze with RuboCop........................................[RuboCop] OK
✗ One or more pre-commit hooks failed

@sds sds merged commit 8f96762 into sds:master Jul 17, 2018
@sds
Copy link
Owner

sds commented Jul 17, 2018

The failure appears spurious—it only seems to occur on Appveyor builds, and non-deterministically.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants