| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 | /* global API */ |
||
| 25 | (function () { |
||
| 26 | 'use strict'; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @ngdoc function |
||
| 30 | * @name passmanApp.controller:MainCtrl |
||
| 31 | * @description |
||
| 32 | * # MainCtrl |
||
| 33 | * Controller of the passmanApp |
||
| 34 | */ |
||
| 35 | angular.module('passmanExtension') |
||
| 36 | .controller('ListCtrl', ['$scope', 'Settings', '$location', '$rootScope', function ($scope, Settings, $window, $rootScope) { |
||
| 37 | $scope.app = 'passman'; |
||
| 38 | |||
| 39 | |||
| 40 | /** |
||
| 41 | * Connect to the background service |
||
| 42 | */ |
||
| 43 | var initApp = function () { |
||
| 44 | API.runtime.sendMessage(API.runtime.id, {method: "getMasterPasswordSet"}).then(function (isPasswordSet) { |
||
| 45 | //First check attributes |
||
| 46 | if (!isPasswordSet) { |
||
| 47 | return; |
||
| 48 | } |
||
| 49 | |||
| 50 | getActiveTab(); |
||
| 51 | }); |
||
| 52 | }; |
||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | var getActiveTab = function () { |
||
| 57 | API.tabs.query({currentWindow: true, active: true}).then(function (tab) { |
||
| 58 | API.runtime.sendMessage(API.runtime.id, { |
||
| 59 | method: "getCredentialsByUrl", |
||
| 60 | args: [tab[0].url] |
||
| 61 | }).then(function (_logins) { |
||
| 62 | //var url = backgroundPage.processURL(tab.url, $rootScope.app_settings.ignoreProtocol, $rootScope.app_settings.ignoreSubdomain, $rootScope.app_settings.ignorePath); |
||
| 63 | $scope.found_credentials = _logins; |
||
| 64 | $scope.$apply(); |
||
| 65 | }); |
||
| 66 | }); |
||
| 67 | }; |
||
| 68 | |||
| 69 | initApp(); |
||
| 70 | |||
| 71 | $scope.editCredential = function (credential) { |
||
| 72 | window.location = '#!/edit/' + credential.guid; |
||
| 73 | }; |
||
| 74 | }]); |
||
| 75 | }()); |
||
| 76 | |||
| 77 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.