diff --git a/.rubocop.yml b/.rubocop.yml index ce1de33..56d1540 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,116 +6,33 @@ AllCops: - Vagrantfile TargetRubyVersion: 2.3 -Style/AccessorMethodName: +Naming/AccessorMethodName: Enabled: false -Style/NumericLiteralPrefix: - Enabled: false -Style/TrailingCommaInArguments: - Enabled: false -Style/TrailingCommaInLiteral: - Enabled: false -Style/FrozenStringLiteralComment: - Enabled: false -Metrics/ParameterLists: - Max: 5 - CountKeywordArgs: false -Style/MutableConstant: + +Lint/RescueWithoutErrorClass: Enabled: false + Metrics/LineLength: Max: 120 -Metrics/AbcSize: +Metrics/CyclomaticComplexity: + Enabled: false +Metrics/PerceivedComplexity: Enabled: false Metrics/MethodLength: Enabled: false Metrics/BlockLength: Enabled: false -Metrics/CyclomaticComplexity: - Enabled: false -Metrics/PerceivedComplexity: - Enabled: false Metrics/ClassLength: Enabled: false -Style/SpaceInsideHashLiteralBraces: - Enabled: false -Style/AsciiComments: - Enabled: true -Style/Documentation: - Enabled: false -Style/SignalException: - Enabled: false -Style/OptionHash: - Enabled: true -Style/SymbolArray: - Enabled: true -Performance/Casecmp: - Enabled: false -Style/DoubleNegation: - Enabled: false -Style/Alias: - EnforcedStyle: prefer_alias_method -Style/MultilineMethodCallIndentation: - EnforcedStyle: indented -Style/RaiseArgs: - EnforcedStyle: exploded -Style/SpaceInLambdaLiteral: - Enabled: false -Lint/UnneededSplatExpansion: +Metrics/AbcSize: Enabled: false - -# Generated configuration -Style/HashSyntax: - Enabled: true - EnforcedStyle: ruby19 - UseHashRocketsWithSymbolValues: false -Style/MethodDefParentheses: - Enabled: true - EnforcedStyle: require_parentheses -Style/MultilineAssignmentLayout: - Enabled: true - EnforcedStyle: new_line -Style/IndentationConsistency: - Enabled: true - EnforcedStyle: normal -Style/AlignParameters: - Enabled: true - EnforcedStyle: with_fixed_indentation -Style/BlockDelimiters: - Enabled: true - EnforcedStyle: line_count_based -Style/AndOr: - Enabled: true -Style/DotPosition: - Enabled: true - EnforcedStyle: leading -Style/EmptyLinesAroundClassBody: - Enabled: true - EnforcedStyle: no_empty_lines -Style/EmptyLinesAroundModuleBody: - Enabled: true - EnforcedStyle: no_empty_lines -Style/NumericPredicate: - Enabled: true - EnforcedStyle: comparison -Style/EvenOdd: +Style/NumericLiteralPrefix: + Enabled: false +Style/FrozenStringLiteralComment: Enabled: false -Style/CollectionMethods: - Enabled: true - PreferredMethods: - collect: map - collect!: map! - inject: reduce - detect: find - find_all: select -Style/EmptyLinesAroundAccessModifier: - Enabled: true Style/CommandLiteral: Enabled: true EnforcedStyle: percent_x -Style/StringLiterals: - Enabled: true - EnforcedStyle: single_quotes -Style/SpaceInsideBlockBraces: - EnforcedStyle: space -Style/VariableNumber: - EnforcedStyle: snake_case +Style/Documentation: + Enabled: false diff --git a/Gemfile b/Gemfile index de2741f..405c4df 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ gem 'locale', '~> 2.1', '>= 2.1.2' gem 'rotp', '~> 3.1', '>= 3.1.0' group :development do - gem 'rubocop', '0.48.1' + gem 'rubocop', '0.50.0' gem 'test-unit' gem 'yard' end diff --git a/bin/mpw-add b/bin/mpw-add index 1d0581a..cdc23b0 100644 --- a/bin/mpw-add +++ b/bin/mpw-add @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/bin/mpw-config b/bin/mpw-config index 0af88bd..e36d2f8 100644 --- a/bin/mpw-config +++ b/bin/mpw-config @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/bin/mpw-copy b/bin/mpw-copy index 95c01d6..01b75aa 100644 --- a/bin/mpw-copy +++ b/bin/mpw-copy @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/bin/mpw-delete b/bin/mpw-delete index ea352c4..78dc340 100644 --- a/bin/mpw-delete +++ b/bin/mpw-delete @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/bin/mpw-export b/bin/mpw-export index 83d35ae..3ab0945 100644 --- a/bin/mpw-export +++ b/bin/mpw-export @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/bin/mpw-genpwd b/bin/mpw-genpwd index 051c5c4..de5628f 100644 --- a/bin/mpw-genpwd +++ b/bin/mpw-genpwd @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/bin/mpw-import b/bin/mpw-import index 76e163e..8213eb3 100644 --- a/bin/mpw-import +++ b/bin/mpw-import @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/bin/mpw-list b/bin/mpw-list index 434ea11..71e7b5a 100644 --- a/bin/mpw-list +++ b/bin/mpw-list @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/bin/mpw-update b/bin/mpw-update index d15b8e7..53ce5f8 100644 --- a/bin/mpw-update +++ b/bin/mpw-update @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/bin/mpw-wallet b/bin/mpw-wallet index caee35d..6f84afd 100644 --- a/bin/mpw-wallet +++ b/bin/mpw-wallet @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/lib/mpw/cli.rb b/lib/mpw/cli.rb index d54b314..7309024 100644 --- a/lib/mpw/cli.rb +++ b/lib/mpw/cli.rb @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # @@ -39,7 +38,7 @@ module MPW @config.setup(options) puts I18n.t('form.set_config.valid').to_s.green - rescue => e + rescue e puts "#{I18n.t('display.error')} #15: #{e}".red exit 2 end @@ -50,7 +49,7 @@ module MPW @config.set_wallet_path(path, @wallet) puts I18n.t('form.set_wallet_path.valid').to_s.green - rescue => e + rescue e puts "#{I18n.t('display.error')} #19: #{e}".red exit 2 end @@ -67,7 +66,7 @@ module MPW load_config puts I18n.t('form.setup_config.valid').to_s.green - rescue => e + rescue e puts "#{I18n.t('display.error')} #8: #{e}".red exit 2 end @@ -89,7 +88,7 @@ module MPW @config.setup_gpg_key(@password, gpg_key) puts I18n.t('form.setup_gpg_key.valid').to_s.green - rescue => e + rescue e puts "#{I18n.t('display.error')} #8: #{e}".red exit 2 end @@ -119,7 +118,7 @@ module MPW # Load config def load_config @config.load_config - rescue => e + rescue e puts "#{I18n.t('display.error')} #10: #{e}".red exit 2 end @@ -140,7 +139,7 @@ module MPW @mpw.read_data end end - rescue => e + rescue e puts "#{I18n.t('display.error')} #11: #{e}".red exit 2 end @@ -416,7 +415,7 @@ module MPW @mpw.write_data puts I18n.t('form.add_key.valid').to_s.green - rescue => e + rescue e puts "#{I18n.t('display.error')} #13: #{e}".red end @@ -427,7 +426,7 @@ module MPW @mpw.write_data puts I18n.t('form.delete_key.valid').to_s.green - rescue => e + rescue e puts "#{I18n.t('display.error')} #15: #{e}".red end @@ -478,7 +477,7 @@ module MPW @mpw.write_data puts I18n.t('form.add_item.valid').to_s.green - rescue => e + rescue e puts "#{I18n.t('display.error')} #13: #{e}".red end @@ -506,7 +505,7 @@ module MPW puts I18n.t('form.update_item.valid').to_s.green end - rescue => e + rescue e puts "#{I18n.t('display.error')} #14: #{e}".red end @@ -530,7 +529,7 @@ module MPW puts I18n.t('form.delete_item.valid').to_s.green end - rescue => e + rescue e puts "#{I18n.t('display.error')} #16: #{e}".red end @@ -548,7 +547,7 @@ module MPW item = get_item(items) clipboard(item, clipboard) end - rescue => e + rescue e puts "#{I18n.t('display.error')} #14: #{e}".red end @@ -578,7 +577,7 @@ module MPW File.open(file, 'w') { |f| f << data.to_yaml } puts I18n.t('form.export.valid', file: file).to_s.green - rescue => e + rescue e puts "#{I18n.t('display.error')} #17: #{e}".red end @@ -613,7 +612,7 @@ module MPW @mpw.write_data puts I18n.t('form.import.valid').to_s.green - rescue => e + rescue e puts "#{I18n.t('display.error')} #18: #{e}".red end end diff --git a/lib/mpw/config.rb b/lib/mpw/config.rb index 95390a4..47440ab 100644 --- a/lib/mpw/config.rb +++ b/lib/mpw/config.rb @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # @@ -39,9 +38,9 @@ module MPW def initialize(config_file = nil) @config_file = config_file @config_dir = - if /darwin/ =~ RUBY_PLATFORM + if RUBY_PLATFORM =~ /darwin/ "#{Dir.home}/Library/Preferences/mpw" - elsif /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM + elsif RUBY_PLATFORM =~ /cygwin|mswin|mingw|bccwin|wince|emx/ "#{Dir.home}/AppData/Local/mpw" else "#{Dir.home}/.config/mpw" @@ -94,7 +93,7 @@ module MPW File.open(@config_file, 'w') do |file| file << config.to_yaml end - rescue => e + rescue e raise "#{I18n.t('error.config.write')}\n#{e}" end @@ -122,7 +121,7 @@ module MPW ctx = GPGME::Ctx.new ctx.genkey(param, nil, nil) - rescue => e + rescue e raise "#{I18n.t('error.config.genkey_gpg.exception')}\n#{e}" end @@ -141,7 +140,7 @@ module MPW raise if @gpg_key.empty? || @wallet_dir.empty? I18n.locale = @lang.to_sym - rescue => e + rescue e raise "#{I18n.t('error.config.load')}\n#{e}" end diff --git a/lib/mpw/import/gorilla.rb b/lib/mpw/import/gorilla.rb index fd5d9f1..a5a8fbe 100644 --- a/lib/mpw/import/gorilla.rb +++ b/lib/mpw/import/gorilla.rb @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/lib/mpw/import/mpw.rb b/lib/mpw/import/mpw.rb index 8d6b1c4..aca88aa 100644 --- a/lib/mpw/import/mpw.rb +++ b/lib/mpw/import/mpw.rb @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/lib/mpw/import/mpw_old.rb b/lib/mpw/import/mpw_old.rb index f6957fe..7f8c33e 100644 --- a/lib/mpw/import/mpw_old.rb +++ b/lib/mpw/import/mpw_old.rb @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/lib/mpw/item.rb b/lib/mpw/item.rb index ec8ab0e..ec4c50e 100644 --- a/lib/mpw/item.rb +++ b/lib/mpw/item.rb @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # diff --git a/lib/mpw/mpw.rb b/lib/mpw/mpw.rb index a5fc0ae..257d3bf 100644 --- a/lib/mpw/mpw.rb +++ b/lib/mpw/mpw.rb @@ -1,4 +1,3 @@ -#!/usr/bin/ruby # MPW is a software to crypt and manage your passwords # Copyright (C) 2017 Adrien Waksberg # @@ -89,14 +88,14 @@ module MPW otp: @otp_keys.key?(d['id']), comment: d['comment'], last_edit: d['last_edit'], - created: d['created'], + created: d['created'] ) ) end end add_key(@key) unless @keys.key?(@key) - rescue => e + rescue e raise "#{I18n.t('error.mpw_file.read_data')}\n#{e}" end @@ -116,7 +115,7 @@ module MPW 'url' => item.url, 'comment' => item.comment, 'last_edit' => item.last_edit, - 'created' => item.created, + 'created' => item.created } ) end @@ -147,7 +146,7 @@ module MPW end File.rename(tmp_file, @wallet_file) - rescue => e + rescue e File.unlink(tmp_file) if File.exist?(tmp_file) raise "#{I18n.t('error.mpw_file.write_data')}\n#{e}" @@ -324,7 +323,7 @@ module MPW crypto .decrypt(data, password) .read.force_encoding('utf-8') - rescue => e + rescue e raise "#{I18n.t('error.gpg_file.decrypt')}\n#{e}" end @@ -342,7 +341,7 @@ module MPW end crypto.encrypt(data, recipients: recipients).read - rescue => e + rescue e raise "#{I18n.t('error.gpg_file.encrypt')}\n#{e}" end end diff --git a/mpw.gemspec b/mpw.gemspec index 4afbe3b..dfb4825 100644 --- a/mpw.gemspec +++ b/mpw.gemspec @@ -1,5 +1,3 @@ -# coding: utf-8 - lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) diff --git a/test/init.rb b/test/init.rb index 6da9ecb..08ebbb8 100644 --- a/test/init.rb +++ b/test/init.rb @@ -1,5 +1,3 @@ -#!/usr/bin/ruby - require 'fileutils' require 'gpgme' diff --git a/test/test_cli.rb b/test/test_cli.rb index 07c4273..9cfe215 100644 --- a/test/test_cli.rb +++ b/test/test_cli.rb @@ -1,5 +1,3 @@ -#!/usr/bin/ruby - require 'i18n' require 'test/unit' diff --git a/test/test_config.rb b/test/test_config.rb index 8ad7369..2b88b54 100644 --- a/test/test_config.rb +++ b/test/test_config.rb @@ -1,5 +1,3 @@ -#!/usr/bin/ruby - require 'mpw/config' require 'test/unit' require 'locale' diff --git a/test/test_import.rb b/test/test_import.rb index c27b58f..101fd1a 100644 --- a/test/test_import.rb +++ b/test/test_import.rb @@ -1,5 +1,3 @@ -#!/usr/bin/ruby - require 'i18n' require 'test/unit' diff --git a/test/test_item.rb b/test/test_item.rb index 80e39ff..97503c0 100644 --- a/test/test_item.rb +++ b/test/test_item.rb @@ -1,5 +1,3 @@ -#!/usr/bin/ruby - require 'mpw/item' require 'test/unit' require 'yaml' diff --git a/test/test_mpw.rb b/test/test_mpw.rb index a1633ef..8fc544e 100644 --- a/test/test_mpw.rb +++ b/test/test_mpw.rb @@ -1,5 +1,3 @@ -#!/usr/bin/ruby - require 'mpw/mpw' require 'mpw/item' require 'test/unit' diff --git a/test/test_translate.rb b/test/test_translate.rb index d4bb002..d7cbceb 100644 --- a/test/test_translate.rb +++ b/test/test_translate.rb @@ -1,5 +1,3 @@ -#!/usr/bin/ruby - require 'yaml' require 'test/unit'