| Conditions | 1 |
| Paths | 4 |
| Total Lines | 150 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /** |
||
| 23 | (function () { |
||
| 24 | 'use strict'; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @ngdoc overview |
||
| 28 | * @name passmanApp |
||
| 29 | * @description |
||
| 30 | * # passmanApp |
||
| 31 | * |
||
| 32 | * Main module of the application. |
||
| 33 | */ |
||
| 34 | angular |
||
| 35 | .module('passmanApp', [ |
||
| 36 | 'ngAnimate', |
||
| 37 | 'ngCookies', |
||
| 38 | 'ngResource', |
||
| 39 | 'ngRoute', |
||
| 40 | 'ngSanitize', |
||
| 41 | 'ngTouch', |
||
| 42 | 'templates-main', |
||
| 43 | 'LocalStorageModule', |
||
| 44 | 'offClick', |
||
| 45 | 'ngPasswordMeter', |
||
| 46 | 'ngclipboard', |
||
| 47 | 'xeditable', |
||
| 48 | 'ngTagsInput', |
||
| 49 | 'angularjs-datetime-picker', |
||
| 50 | 'ui.sortable' |
||
| 51 | ]) |
||
| 52 | .config(function ($routeProvider) { |
||
| 53 | $routeProvider |
||
| 54 | .when('/', { |
||
| 55 | templateUrl: 'views/vaults.html', |
||
| 56 | controller: 'VaultCtrl' |
||
| 57 | }) |
||
| 58 | .when('/vault/:vault_id', { |
||
| 59 | templateUrl: 'views/show_vault.html', |
||
| 60 | controller: 'CredentialCtrl' |
||
| 61 | }) |
||
| 62 | .when('/vault/:vault_id/new', { |
||
| 63 | templateUrl: 'views/edit_credential.html', |
||
| 64 | controller: 'CredentialEditCtrl' |
||
| 65 | }) |
||
| 66 | .when('/vault/:vault_id/edit/:credential_id', { |
||
| 67 | templateUrl: 'views/edit_credential.html', |
||
| 68 | controller: 'CredentialEditCtrl' |
||
| 69 | }).when('/vault/:vault_id/:credential_id/share', { |
||
| 70 | templateUrl: 'views/share_credential.html', |
||
| 71 | controller: 'ShareCtrl' |
||
| 72 | }).when('/vault/:vault_id/:credential_id/revisions', { |
||
| 73 | templateUrl: 'views/credential_revisions.html', |
||
| 74 | controller: 'RevisionCtrl' |
||
| 75 | }) |
||
| 76 | .when('/vault/:vault_id/settings', { |
||
| 77 | templateUrl: 'views/settings.html', |
||
| 78 | controller: 'SettingsCtrl' |
||
| 79 | }) |
||
| 80 | .otherwise({ |
||
| 81 | redirectTo: '/' |
||
| 82 | }); |
||
| 83 | }).config(['$httpProvider', function ($httpProvider) { |
||
| 84 | $httpProvider.defaults.headers.common.requesttoken = oc_requesttoken; |
||
|
|
|||
| 85 | }]).config(function (localStorageServiceProvider) { |
||
| 86 | localStorageServiceProvider |
||
| 87 | .setNotify(true, true); |
||
| 88 | }); |
||
| 89 | |||
| 90 | /** |
||
| 91 | * jQuery for notification handling D: |
||
| 92 | **/ |
||
| 93 | jQuery(document).ready(function () { |
||
| 94 | var findItemByID = function (id) { |
||
| 95 | var credentials, foundItem = false; |
||
| 96 | credentials = angular.element('#app-content-wrapper').scope().credentials; |
||
| 97 | angular.forEach(credentials, function (credential) { |
||
| 98 | if (credential.credential_id === id) { |
||
| 99 | foundItem = credential; |
||
| 100 | } |
||
| 101 | }); |
||
| 102 | return foundItem; |
||
| 103 | }; |
||
| 104 | jQuery(document).on('click', '.undoDelete', function () { |
||
| 105 | var credential = findItemByID($(this).attr('data-item-id')); |
||
| 106 | angular.element('#app-content-wrapper').scope().recoverCredential(credential); |
||
| 107 | //Outside anglular we need $apply |
||
| 108 | angular.element('#app-content-wrapper').scope().$apply(); |
||
| 109 | }); |
||
| 110 | jQuery(document).on('click', '.undoRestore', function () { |
||
| 111 | var credential = findItemByID($(this).attr('data-item-id')); |
||
| 112 | angular.element('#app-content-wrapper').scope().deleteCredential(credential); |
||
| 113 | //Outside anglular we need $apply |
||
| 114 | angular.element('#app-content-wrapper').scope().$apply(); |
||
| 115 | }); |
||
| 116 | var adjustControlsWidth = function (r) { |
||
| 117 | if ($('#controls').length) { |
||
| 118 | var controlsWidth; |
||
| 119 | // if there is a scrollbar … |
||
| 120 | if ($('#app-content').get(0)) { |
||
| 121 | if ($('#app-content').get(0).scrollHeight > $('#app-content').height()) { |
||
| 122 | if ($(window).width() > 768) { |
||
| 123 | controlsWidth = $('#content').width() - $('#app-navigation').width() - OC.Util.getScrollBarWidth(); |
||
| 124 | if (!$('#app-sidebar').hasClass('hidden') && !$('#app-sidebar').hasClass('disappear')) { |
||
| 125 | controlsWidth -= $('#app-sidebar').width(); |
||
| 126 | } |
||
| 127 | } else { |
||
| 128 | controlsWidth = $('#content').width() - OC.Util.getScrollBarWidth(); |
||
| 129 | } |
||
| 130 | } else { // if there is none |
||
| 131 | if ($(window).width() > 768) { |
||
| 132 | controlsWidth = $('#content').width() - $('#app-navigation').width(); |
||
| 133 | if (!$('#app-sidebar').hasClass('hidden') && !$('#app-sidebar').hasClass('disappear')) { |
||
| 134 | //controlsWidth -= $('#app-sidebar').width(); |
||
| 135 | } |
||
| 136 | } else { |
||
| 137 | controlsWidth = $('#content').width(); |
||
| 138 | } |
||
| 139 | } |
||
| 140 | } |
||
| 141 | var magic; |
||
| 142 | if (r) { |
||
| 143 | magic = 0; |
||
| 144 | } else { |
||
| 145 | magic = 85; |
||
| 146 | } |
||
| 147 | $('#controls').css('width', controlsWidth + magic); |
||
| 148 | $('#controls').css('min-width', controlsWidth + magic); |
||
| 149 | } |
||
| 150 | }; |
||
| 151 | /* |
||
| 152 | $(window).resize(adjustControlsWidth, 400); |
||
| 153 | setTimeout(function () { |
||
| 154 | adjustControlsWidth(true); |
||
| 155 | }, 200);*/ |
||
| 156 | |||
| 157 | //@Fack this |
||
| 158 | /* |
||
| 159 | $(document).on('click', '#app-navigation-toggle', function () { |
||
| 160 | setTimeout(function () { |
||
| 161 | if ($('#app-content').css('transform').toString().indexOf('matrix') >= 0) { |
||
| 162 | $('#passman-controls').css('width', 'calc( 100% - 245px)'); |
||
| 163 | $('#passman-controls').css('top', '0'); |
||
| 164 | } else { |
||
| 165 | $('#passman-controls').css('left', 0); |
||
| 166 | $('#passman-controls').css('top', '44px'); |
||
| 167 | $('#passman-controls').css('width', '100%'); |
||
| 168 | } |
||
| 169 | }, 350); |
||
| 170 | });*/ |
||
| 171 | }); |
||
| 172 | }()); |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.