-
Notifications
You must be signed in to change notification settings - Fork 27
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
imports actualized #1338
base: develop
Are you sure you want to change the base?
imports actualized #1338
Conversation
WalkthroughThe changes in this pull request involve several updates across different files, primarily focusing on improving import statements by replacing broad imports from the Ember namespace with specific imports from respective Ember modules. Notable modifications include the replacement of Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant FlexberryFileComponent
participant UniqueIdGenerator
User->>FlexberryFileComponent: Interacts with file input
FlexberryFileComponent->>UniqueIdGenerator: Request unique ID
UniqueIdGenerator-->>FlexberryFileComponent: Return unique ID
FlexberryFileComponent-->>User: Display file input with unique ID
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
🧹 Outside diff range and nitpick comments (11)
addon/services/compatibility-validations.js (1)
5-7
: LGTM with minor spacing issue.The migration to specific Ember imports is correct, but there's an extra space after 'from' in line 5.
-import Service from '@ember/service'; +import Service from '@ember/service';tests/unit/services/user-settings-test.js (2)
Line range hint
10-17
: Fix inconsistent usage of getOwner stub.There's an inconsistency between the stub creation and restoration. The beforeEach uses
Ember.getOwner
while the afterEach uses the importedgetOwner
.Apply this diff to maintain consistency:
beforeEach() { - sinon.stub(Ember, 'getOwner').returns( + sinon.stub(getOwner).returns( { resolveRegistration: () =>({ APP: { components: { flexberryObjectlistview: { defaultPerPage: 5 } } } }), factoryFor: () =>({ class: { APP: {} }}) }) }, afterEach() { getOwner.restore(); }Also, consider fixing the indentation in the stub configuration for better readability:
beforeEach() { sinon.stub(getOwner).returns({ resolveRegistration: () => ({ APP: { components: { flexberryObjectlistview: { defaultPerPage: 5 } } } }), factoryFor: () => ({ class: { APP: {} } }) }) },
4-4
: Consider removing unused Ember import.After updating the getOwner usage, the
Ember
import appears to be unused and can be removed.-import Ember from 'ember';
tests/integration/components/flexberry/validation-summary-test.js (1)
1-2
: Consider grouping related imports together.For better organization, consider grouping the Ember-related imports together. This makes the imports more maintainable and easier to scan.
-import { A } from '@ember/array'; -import { run } from '@ember/runloop'; import { moduleForComponent, test } from 'ember-qunit'; +import { A } from '@ember/array'; +import { run } from '@ember/runloop'; import hbs from 'htmlbars-inline-precompile';tests/unit/services/device-test.js (1)
Migration needed: Replace
Ember.getOwner
with importedgetOwner
in user-settings.jsThe verification has revealed an inconsistency in
addon/services/user-settings.js
:
- The file imports
getOwner
from@ember/application
- But still uses the deprecated
Ember.getOwner
syntaxThis needs to be updated to use the imported
getOwner
directly, similar to the change being made in the test file.🔗 Analysis chain
Line range hint
1-14
: Verify the impact of getOwner changesLet's verify that there are no other instances of
Ember.getOwner
usage in the codebase that should be updated as part of this migration.
Let me check the specific usage of
Ember.getOwner
in the identified file to ensure we provide accurate guidance.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any remaining usage of Ember.getOwner echo "Checking for remaining Ember.getOwner usage:" rg "Ember\.getOwner" -l # Search for imported getOwner usage to verify consistency echo -e "\nChecking current getOwner import patterns:" rg "import.*getOwner.*from '@ember/application'" -lLength of output: 1145
Script:
#!/bin/bash # Check the specific usage of Ember.getOwner in user-settings.js echo "Checking Ember.getOwner usage in user-settings.js:" rg "Ember\.getOwner" -A 3 -B 3 "addon/services/user-settings.js" # Check if getOwner is also imported in the same file echo -e "\nChecking getOwner import in the same file:" rg "import.*getOwner" "addon/services/user-settings.js"Length of output: 654
tests/dummy/app/controllers/log-service-examples/settings-example.js (2)
Line range hint
1-254
: Update method names to reflect console-based logging.Since Ember.Logger is being replaced with native console methods, the button action names should be updated to reflect this change:
- buttonName: this.get('i18n').t('forms.log-service-examples.settings-example.ember-logger-error-button-caption'), - buttonAction: 'onEmberLoggerErrorButtonClick', + buttonName: this.get('i18n').t('forms.log-service-examples.settings-example.console-error-button-caption'), + buttonAction: 'onConsoleErrorButtonClick', // Similar changes for other logger-related button actionsRemember to update the corresponding method names and i18n translations.
Based on the gathered information, I can now provide a final response:
Ember.Logger usage needs to be updated to modern logging approach
The codebase shows inconsistent logging patterns that need to be addressed:
- The file under review (settings-example.js) still uses deprecated
Ember.Logger
methods- The log service (addon/services/log.js) has already migrated to using console methods directly (console.warn, console.log, etc.)
- The CHANGELOG indicates a previous migration from
Ember.Logger.xxx
toEmber.xxx
Required changes:
- Replace
Ember.Logger.error
withconsole.error
- Replace
Ember.Logger.warn
withconsole.warn
- Replace
Ember.Logger.log
withconsole.log
- Replace
Ember.Logger.info
withconsole.info
- Replace
Ember.Logger.debug
withconsole.debug
The changes should maintain consistency with the logging service implementation in addon/services/log.js which has already been modernized.
🔗 Analysis chain
Line range hint
1-254
: Verify consistency of logging approach across the codebase.Let's ensure the logging changes are consistent across the codebase.
Let me analyze the results and gather more specific information about the Ember.Logger usage to provide a concrete recommendation.
Let's see the actual implementation details to understand if there's a migration pattern we need to follow or if there are inconsistencies that need to be addressed.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for remaining Ember.Logger usage and verify logging approach consistency # Test 1: Check for remaining Ember.Logger usage echo "Checking for remaining Ember.Logger usage..." rg "Ember\.Logger\." -l # Test 2: Check for console logging patterns echo "Checking for console logging patterns..." rg "console\.(error|warn|info|log|debug)" -l # Test 3: Check for generateUniqueId usage echo "Checking for generateUniqueId usage patterns..." rg "generateUniqueId" -lLength of output: 2793
Script:
#!/bin/bash # Get detailed context of remaining Ember.Logger usage echo "Checking Ember.Logger usage in addon/services/log.js..." rg "Ember\.Logger\." -A 3 -B 3 addon/services/log.js echo -e "\nChecking Ember.Logger usage in tests/unit/services/log-test.js..." rg "Ember\.Logger\." -A 3 -B 3 tests/unit/services/log-test.js echo -e "\nChecking CHANGELOG.md for Logger-related changes..." rg "Logger" -A 3 -B 3 CHANGELOG.mdLength of output: 4953
addon/components/flexberry-file.js (3)
4-4
: Add tests for the file component.The TODO comment indicates missing tests. Consider adding comprehensive tests covering:
- File upload/download functionality
- Error handling scenarios
- Unique ID generation
Would you like me to help create a test suite for this component?
Line range hint
1012-1029
: Consider enhancing error handling in uploadFile method.The error handling could be improved by:
- Adding more specific error types
- Including better error context in the reject case
- Logging errors for debugging
Consider this enhancement:
}).fail((jqXhr, textStatus, errorThrown) => { - let errorContent = this.showUploadErrorModalDialog(file.name, errorThrown ? ' (' + errorThrown + ')' : ''); + let errorDetails = { + status: jqXhr.status, + statusText: jqXhr.statusText, + error: errorThrown || 'Unknown error' + }; + let errorContent = this.showUploadErrorModalDialog( + file.name, + `(${errorDetails.status}: ${errorDetails.error})` + ); + console.error('File upload failed:', errorDetails); if (!isNone(this.get('uploadFail'))) { this.get('uploadFail')({ uploadData: uploadData, response: jqXhr, + error: errorDetails, value: this.get('value') }); } - reject(new Error(errorContent)); + reject(Object.assign(new Error(errorContent), { details: errorDetails })); })
Line range hint
32-38
: Add JSDoc documentation for the _fileInputId computed property.The computed property lacks proper documentation explaining its purpose and behavior.
Add documentation like this:
/** * Generates a unique identifier for the file input element. * @property _fileInputId * @type {String} * @private * @computed elementId * @returns {String} A unique identifier either based on the elementId or generated using generateUniqueId */addon/services/log.js (1)
401-404
: Avoid overriding globalconsole.error
methodOverriding the global
console.error
can have unintended side effects on other parts of the application and third-party libraries that rely on the originalconsole
methods.Instead of overriding global methods, consider extending the console functionality or creating a separate logging service to handle custom logging needs without affecting global behavior.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (14)
- addon/components/flexberry-file.js (2 hunks)
- addon/components/flexberry/validation-summary.js (1 hunks)
- addon/services/compatibility-validations.js (1 hunks)
- addon/services/log.js (2 hunks)
- tests/acceptance/components/flexberry-groupedit/flexberry-groupedit-sort-test.js (3 hunks)
- tests/acceptance/components/flexberry-objectlistview/folv-user-settings-test.js (6 hunks)
- tests/dummy/app/controllers/log-service-examples/settings-example.js (2 hunks)
- tests/dummy/app/locales/en/translations.js (1 hunks)
- tests/dummy/app/locales/ru/translations.js (1 hunks)
- tests/dummy/app/models/ember-flexberry-dummy-application-user.js (0 hunks)
- tests/integration/components/flexberry/validation-summary-test.js (1 hunks)
- tests/unit/services/compatibility-validations-test.js (1 hunks)
- tests/unit/services/device-test.js (2 hunks)
- tests/unit/services/user-settings-test.js (2 hunks)
💤 Files with no reviewable changes (1)
- tests/dummy/app/models/ember-flexberry-dummy-application-user.js
🧰 Additional context used
🔇 Additional comments (19)
tests/unit/services/user-settings-test.js (1)
5-5
: LGTM! Good modernization of Ember imports.The change to import
getOwner
from@ember/application
aligns with modern Ember practices and helps with tree-shaking.addon/components/flexberry/validation-summary.js (1)
5-6
: LGTM! Import statements modernized correctly.The changes follow Ember Octane's best practices by replacing the monolithic
Ember
import with specific module imports. This change enables better tree-shaking and aligns with modern Ember patterns.Let's verify if there are any remaining legacy Ember imports in the component:
✅ Verification successful
Let me gather more information about the component's implementation to ensure there are no remaining legacy patterns that need modernization.
This will help us verify:
- If there are any remaining legacy Ember patterns
- If all imports are properly modernized
- If the component's functionality relies on any other Ember features that might need updating
Import modernization is complete and correct
After reviewing the complete component implementation, I can confirm that:
- All Ember imports are properly modernized using the new module syntax
- The component uses
computed.notEmpty
correctly through the importedcomputed
from@ember/object
- There are no remaining legacy
Ember.*
patterns in the code- The component follows modern Ember practices while maintaining its functionality
The original review comment was accurate in its assessment.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any remaining Ember.* usage in the component # that might need modernization rg -A 2 "Ember\." "addon/components/flexberry/validation-summary.js"Length of output: 68
Script:
#!/bin/bash # Check the entire content of the validation-summary component cat "addon/components/flexberry/validation-summary.js"Length of output: 1498
tests/unit/services/compatibility-validations-test.js (3)
1-1
: LGTM! Import modernization looks good.The change from
Ember.get
to a direct import from@ember/object
aligns with modern Ember practices and enables better tree-shaking.
Line range hint
19-35
: Test structure and assertions look good.The test case effectively verifies that all validators are properly cached in the service. The initialization and assertions are well-structured.
Line range hint
1-13
: Consider modernizing remaining imports.While we're updating imports, consider using the new module imports for the validation-related imports as well. Let's verify if newer import paths are available.
tests/integration/components/flexberry/validation-summary-test.js (1)
1-2
: LGTM! Import modernization looks good.The change from using the broad
Ember
import to specific imports from@ember/array
and@ember/runloop
follows modern Ember best practices and improves code maintainability.tests/acceptance/components/flexberry-groupedit/flexberry-groupedit-sort-test.js (5)
1-2
: LGTM! Import statements follow modern Ember practices.The replacement of broad Ember imports with specific module imports from
@ember/array
and@ember/runloop
improves code clarity and follows current Ember best practices.
23-23
: LGTM! Proper run loop usage in cleanup.The change from
Ember.run
torun
correctly utilizes the imported function while maintaining the same cleanup functionality.
29-29
: LGTM! Proper array creation using modern syntax.The change from
Ember.A
toA
correctly utilizes the imported function while maintaining the same array initialization functionality.
31-31
: LGTM! Proper run loop usage in test setup.The change from
Ember.run
torun
correctly utilizes the imported function for handling async operations during test record creation.
Line range hint
133-137
: LGTM! Proper run loop usage in test cleanup.The change from
Ember.run
torun
correctly utilizes the imported function for handling async operations during test record cleanup.tests/acceptance/components/flexberry-objectlistview/folv-user-settings-test.js (3)
1-3
: LGTM! Import changes follow modern Ember practices.The replacement of Ember namespace imports with specific module imports improves code maintainability and follows current Ember best practices.
32-32
: LGTM! Service property modifications are properly implemented.The use of the imported
set
function for modifying service properties is consistent and correct. The changes maintain the test's functionality while following modern Ember patterns.Also applies to: 37-37, 147-147
38-38
: LGTM! Run loop usage is properly implemented.The changes correctly utilize the imported
run
function for managing async operations and test cleanup. The implementation maintains proper test isolation and follows Ember's run loop best practices.Also applies to: 54-54, 187-187
tests/dummy/app/controllers/log-service-examples/settings-example.js (1)
254-254
: LGTM: Successful migration to generateUniqueId utility.The replacement of Ember's guid generation with the new
generateUniqueId
utility is correct and aligns with the PR's goal of actualizing imports.addon/components/flexberry-file.js (2)
5-5
: LGTM: Import change aligns with modern practices.The addition of
generateUniqueId
import from a dedicated utility module is a good practice, moving away from the Ember namespace.
65-67
: LGTM: Clean implementation of unique ID generation.The computed property correctly handles both cases:
- Uses the provided elementId when available
- Falls back to generateUniqueId() when elementId is blank
tests/dummy/app/locales/en/translations.js (1)
716-721
: LGTM! Translation strings updated to reflect console method usage.The changes correctly update the translation strings to match the transition from Ember.Logger to native console methods, maintaining consistency with the underlying implementation changes.
tests/dummy/app/locales/ru/translations.js (1)
716-721
: LGTM! Logging message strings updated to reflect console methods.The changes correctly update the Russian translation strings to reference the standard console methods instead of Ember.Logger, maintaining consistency with the modernized logging implementation.
import Service from '@ember/service'; | ||
import { set } from '@ember/object'; | ||
import { getOwner } from '@ember/application'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Update remaining Ember namespace usage for consistency
The verification revealed two types of inconsistencies that need to be addressed:
- In
app-state.js
andadv-limit.js
: TheEmber.Service
references appear only in JSDoc comments and don't affect the actual code since both files are already using the importedService
. - In
user-settings.js
: There's an actual usage ofEmber.getOwner
that should be updated to use the imported version for consistency.
Specific locations needing attention:
addon/services/user-settings.js
: ReplaceEmber.getOwner
with the importedgetOwner
from '@ember/application'
🔗 Analysis chain
Verify consistency of import changes across the codebase.
Let's ensure these import changes are consistently applied across all files using these Ember features.
Let me check the specific usage in the files that still use the Ember namespace to determine if there are inconsistencies that need to be addressed.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining usage of Ember.Service, Ember.set, and Ember.getOwner
# that might need to be updated for consistency.
echo "Checking for remaining Ember namespace usage..."
rg -l "Ember\.(Service|set|getOwner)" --type js
echo "Verifying new import pattern usage..."
rg -l "import (Service|set|getOwner) from '@ember/" --type js
Length of output: 743
Script:
#!/bin/bash
# Check the actual usage context in files still using Ember namespace
echo "Checking app-state.js..."
rg "Ember\.(Service|set|getOwner)" addon/services/app-state.js -B 2 -A 2
echo -e "\nChecking adv-limit.js..."
rg "Ember\.(Service|set|getOwner)" addon/services/adv-limit.js -B 2 -A 2
echo -e "\nChecking user-settings.js..."
rg "Ember\.(Service|set|getOwner)" addon/services/user-settings.js -B 2 -A 2
Length of output: 985
@@ -10,7 +11,7 @@ module('Unit | Service | device', { | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent usage of getOwner between setup and teardown
The code uses Ember.getOwner
in beforeEach
but getOwner
in afterEach
. This inconsistency should be resolved by using the imported getOwner
consistently.
Update the beforeEach
hook to use the imported getOwner
:
beforeEach() {
- sinon.stub(Ember, 'getOwner').returns({ application: { deviceService: {} } });
+ sinon.stub(getOwner).returns({ application: { deviceService: {} } });
},
Also applies to: 14-14
import Ember from 'ember'; | ||
import { getOwner } from '@ember/application'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complete the migration from Ember namespace imports
While you've added the specific import for getOwner
, the code still relies on the global Ember
import. This is inconsistent with the PR's objective of actualizing imports.
Consider updating the imports to fully migrate away from the global Ember
namespace:
-import Ember from 'ember';
import { getOwner } from '@ember/application';
Committable suggestion was skipped due to low confidence.
let $perPageElement = $('div.flexberry-dropdown div.text'); | ||
assert.equal($perPageElement.length, 1, "Элемент количества записей на странице найден."); | ||
assert.equal($perPageElement.text(), expectedCount, `Количество элементов на странице равно заданному: ${expectedCount}.`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider using data-test- selectors for more reliable tests.*
While the jQuery usage is correct, the selector 'div.flexberry-dropdown div.text'
is somewhat fragile. Consider using dedicated test selectors for more reliable and maintainable tests.
- let $perPageElement = $('div.flexberry-dropdown div.text');
+ let $perPageElement = $('[data-test-per-page-dropdown]');
Also update the corresponding component template to include the test selector:
<div class="flexberry-dropdown" data-test-per-page-dropdown>
<div class="text">
{{perPage}}
</div>
</div>
import Ember from 'ember'; //TODO Import Module. Replace Ember.Logger | ||
// import { generateGuid } from '@ember/object/internals'; | ||
import generateUniqueId from 'ember-flexberry-data/utils/generate-unique-id'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complete the TODO: Replace Ember.Logger usage with native console methods.
The TODO comment indicates that Ember.Logger needs to be replaced, but the file still uses Ember.Logger in multiple places. This is inconsistent with the PR's goal of actualizing imports.
Replace Ember.Logger with native console methods throughout the file. For example:
-Ember.Logger.error(...)
+console.error(...)
-Ember.Logger.log(...)
+console.log(...)
-Ember.Logger.info(...)
+console.info(...)
Committable suggestion was skipped due to low confidence.
console.warn = function(warn) { | ||
originalEmberLoggerError(warn); | ||
_this._onError(warn, true); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect use of originalEmberLoggerError
in console method overrides
In the overridden console
methods (warn
, deprecated
, log
, info
, debug
), you're calling originalEmberLoggerError
instead of the corresponding original methods. This causes all logs to be treated as errors, which may lead to incorrect logging levels and confusion.
To fix this, call the appropriate original console method in each override. Ensure that you've cached these original methods correctly.
Apply this diff to fix the issue:
// Override console.warn
console.warn = function(warn) {
- originalEmberLoggerError(warn);
+ originalEmberLoggerWarn(warn);
_this._onError(warn, true);
};
// Override console.deprecated
console.deprecated = function(deprecate) {
- originalEmberLoggerError(deprecate);
+ originalEmberLoggerDeprecate(deprecate);
_this._onError(deprecate, true);
};
// Override console.log
console.log = function(log) {
- originalEmberLoggerError(log);
+ originalEmberLoggerLog(log);
_this._onError(log, true);
};
// Override console.info
console.info = function(info) {
- originalEmberLoggerError(info);
+ originalEmberLoggerInfo(info);
_this._onError(info, true);
};
// Override console.debug
console.debug = function(debug) {
- originalEmberLoggerError(debug);
+ originalEmberLoggerDebug(debug);
_this._onError(debug, true);
};
Also applies to: 411-414, 416-419, 421-424, 426-429
console.deprecated = function(deprecate) { | ||
originalEmberLoggerError(deprecate); | ||
_this._onError(deprecate, true); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usage of non-standard console.deprecated
method
The console
object does not have a standard deprecated
method. Adding non-standard methods to the global console
object may lead to confusion and compatibility issues.
Consider using console.warn
with a clear deprecation message or creating a custom method within your logging service to handle deprecation notices.
// } | ||
// }); | ||
// }; | ||
|
||
// Extend Ember.Logger.log logic. | ||
let originalEmberLoggerLog = Ember.Logger.log; | ||
let originalEmberLoggerLog = console.log.bind; | ||
originalMethodsCache.pushObject({ | ||
methodOwner: Ember.Logger, | ||
methodOwner: console, | ||
methodName: 'log', | ||
methodReference: originalEmberLoggerLog | ||
}); | ||
|
||
Ember.Logger.log = function() { | ||
originalEmberLoggerLog(...arguments); | ||
// Ember.Logger.log = function() { | ||
// originalEmberLoggerLog(...arguments); | ||
|
||
return _this._queue.attach((resolve, reject) => { | ||
return _this._storeToApplicationLog(messageCategory.log, joinArguments(...arguments), '').then((result) => { | ||
resolve(result); | ||
}).catch((reason) => { | ||
reject(reason); | ||
}); | ||
}); | ||
}; | ||
// return _this._queue.attach((resolve, reject) => { | ||
// return _this._storeToApplicationLog(messageCategory.log, joinArguments(...arguments), '').then((result) => { | ||
// resolve(result); | ||
// }).catch((reason) => { | ||
// reject(reason); | ||
// }); | ||
// }); | ||
// }; | ||
|
||
// Extend Ember.Logger.info logic. | ||
let originalEmberLoggerInfo = Ember.Logger.info; | ||
let originalEmberLoggerInfo = console.info; | ||
originalMethodsCache.pushObject({ | ||
methodOwner: Ember.Logger, | ||
methodOwner: console, | ||
methodName: 'info', | ||
methodReference: originalEmberLoggerInfo | ||
}); | ||
|
||
Ember.Logger.info = function() { | ||
originalEmberLoggerInfo(...arguments); | ||
// Ember.Logger.info = function() { | ||
// originalEmberLoggerInfo(...arguments); | ||
|
||
return _this._queue.attach((resolve, reject) => { | ||
return _this._storeToApplicationLog(messageCategory.info, joinArguments(...arguments), '').then((result) => { | ||
resolve(result); | ||
}).catch((reason) => { | ||
reject(reason); | ||
}); | ||
}); | ||
}; | ||
// return _this._queue.attach((resolve, reject) => { | ||
// return _this._storeToApplicationLog(messageCategory.info, joinArguments(...arguments), '').then((result) => { | ||
// resolve(result); | ||
// }).catch((reason) => { | ||
// reject(reason); | ||
// }); | ||
// }); | ||
// }; | ||
|
||
// Extend Ember.Logger.debug logic. | ||
let originalEmberLoggerDebug = Ember.Logger.debug; | ||
let originalEmberLoggerDebug = console.debug; | ||
originalMethodsCache.pushObject({ | ||
methodOwner: Ember.Logger, | ||
methodOwner: console, | ||
methodName: 'debug', | ||
methodReference: originalEmberLoggerDebug | ||
}); | ||
|
||
Ember.Logger.debug = function() { | ||
originalEmberLoggerDebug(...arguments); | ||
|
||
return _this._queue.attach((resolve, reject) => { | ||
return _this._storeToApplicationLog(messageCategory.debug, joinArguments(...arguments), '').then((result) => { | ||
resolve(result); | ||
}).catch((reason) => { | ||
reject(reason); | ||
}); | ||
}); | ||
}; | ||
// Ember.Logger.debug = function() { | ||
// originalEmberLoggerDebug(...arguments); | ||
|
||
// return _this._queue.attach((resolve, reject) => { | ||
// return _this._storeToApplicationLog(messageCategory.debug, joinArguments(...arguments), '').then((result) => { | ||
// resolve(result); | ||
// }).catch((reason) => { | ||
// reject(reason); | ||
// }); | ||
// }); | ||
// }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Remove commented-out code for better maintainability
There are large blocks of commented-out code related to Ember.Logger
methods from lines 436 to 535. Keeping obsolete code can clutter the codebase and reduce readability.
If this code is no longer needed, consider removing it to clean up the codebase.
let originalEmberLoggerError = console.error; | ||
originalMethodsCache.pushObject({ | ||
methodOwner: Ember.Logger, | ||
methodOwner: console, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Ensure correct context when caching original console methods
When caching the original console
methods, it's important to bind them to the console
object to preserve the correct context, especially for methods like console.log
.
Modify the caching of the original methods to include binding:
let originalEmberLoggerError = console.error;
+originalEmberLoggerError = originalEmberLoggerError.bind(console);
originalMethodsCache.pushObject({
methodOwner: console,
methodName: 'error',
methodReference: originalEmberLoggerError
});
Repeat this binding for other console methods as needed.
Committable suggestion was skipped due to low confidence.
#1337
Summary by CodeRabbit
Release Notes
New Features
phone1IsRequired
to enhance validation logic for phone number input.Bug Fixes
Refactor
Documentation
These updates enhance the application's functionality, improve code maintainability, and ensure a more consistent user experience.