Conditions | 1 |
Paths | 1 |
Total Lines | 110 |
Code Lines | 72 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 | <?php |
||
36 | protected function _prepareForm() |
||
37 | { |
||
38 | $userId = $this->_authSession->getUser()->getId(); |
||
39 | $user = $this->_userFactory->create()->load($userId); |
||
40 | $user->unsetData('password'); |
||
41 | |||
42 | /** @var \Magento\Framework\Data\Form $form */ |
||
43 | $form = $this->_formFactory->create(); |
||
44 | |||
45 | $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Account Information')]); |
||
46 | |||
47 | $fieldset->addField( |
||
48 | 'username', |
||
49 | 'text', |
||
50 | ['name' => 'username', 'label' => __('User Name'), 'title' => __('User Name'), 'required' => true] |
||
51 | ); |
||
52 | |||
53 | $fieldset->addField( |
||
54 | 'firstname', |
||
55 | 'text', |
||
56 | ['name' => 'firstname', 'label' => __('First Name'), 'title' => __('First Name'), 'required' => true] |
||
57 | ); |
||
58 | |||
59 | $fieldset->addField( |
||
60 | 'lastname', |
||
61 | 'text', |
||
62 | ['name' => 'lastname', 'label' => __('Last Name'), 'title' => __('Last Name'), 'required' => true] |
||
63 | ); |
||
64 | |||
65 | $fieldset->addField('user_id', 'hidden', ['name' => 'user_id']); |
||
66 | |||
67 | $fieldset->addField( |
||
68 | 'email', |
||
69 | 'text', |
||
70 | ['name' => 'email', 'label' => __('Email'), 'title' => __('User Email'), 'required' => true] |
||
71 | ); |
||
72 | |||
73 | $fieldset->addField( |
||
74 | 'password', |
||
75 | 'password', |
||
76 | [ |
||
77 | 'name' => 'password', |
||
78 | 'label' => __('New Password'), |
||
79 | 'title' => __('New Password'), |
||
80 | 'class' => 'validate-admin-password' |
||
81 | ] |
||
82 | ); |
||
83 | |||
84 | $fieldset->addField( |
||
85 | 'confirmation', |
||
86 | 'password', |
||
87 | [ |
||
88 | 'name' => 'password_confirmation', |
||
89 | 'label' => __('Password Confirmation'), |
||
90 | 'class' => 'validate-cpassword' |
||
91 | ] |
||
92 | ); |
||
93 | |||
94 | $fieldset->addField( |
||
95 | 'interface_locale', |
||
96 | 'select', |
||
97 | [ |
||
98 | 'name' => 'interface_locale', |
||
99 | 'label' => __('Interface Locale'), |
||
100 | 'title' => __('Interface Locale'), |
||
101 | 'values' => $this->deployedLocales->getTranslatedOptionLocales(), |
||
102 | 'class' => 'select' |
||
103 | ] |
||
104 | ); |
||
105 | |||
106 | $fieldset->addField( |
||
107 | 'use_devdashboard', |
||
108 | 'select', |
||
109 | [ |
||
110 | 'name' => 'use_devdashboard', |
||
111 | 'label' => __('Use developer dashboard as default'), |
||
112 | 'title' => __('Use developer dashboard'), |
||
113 | 'values' => $this->yesno->toOptionArray(), |
||
114 | 'class' => 'select' |
||
115 | ] |
||
116 | ); |
||
117 | |||
118 | $verificationFieldset = $form->addFieldset( |
||
119 | 'current_user_verification_fieldset', |
||
120 | ['legend' => __('Current User Identity Verification')] |
||
121 | ); |
||
122 | $verificationFieldset->addField( |
||
123 | self::IDENTITY_VERIFICATION_PASSWORD_FIELD, |
||
124 | 'password', |
||
125 | [ |
||
126 | 'name' => self::IDENTITY_VERIFICATION_PASSWORD_FIELD, |
||
127 | 'label' => __('Your Password'), |
||
128 | 'id' => self::IDENTITY_VERIFICATION_PASSWORD_FIELD, |
||
129 | 'title' => __('Your Password'), |
||
130 | 'class' => 'validate-current-password required-entry', |
||
131 | 'required' => true |
||
132 | ] |
||
133 | ); |
||
134 | |||
135 | $data = $user->getData(); |
||
136 | unset($data[self::IDENTITY_VERIFICATION_PASSWORD_FIELD]); |
||
137 | $form->setValues($data); |
||
138 | $form->setAction($this->getUrl('adminhtml/system_account/save')); |
||
139 | $form->setMethod('post'); |
||
140 | $form->setUseContainer(true); |
||
141 | $form->setId('edit_form'); |
||
142 | |||
143 | $this->setForm($form); |
||
144 | |||
145 | return \Magento\Backend\Block\Widget\Form::_prepareForm(); |
||
146 | } |
||
148 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths