Skip to content
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

Improve Includes panel #598

Merged
merged 7 commits into from
Mar 8, 2018
Merged

Improve Includes panel #598

merged 7 commits into from
Mar 8, 2018

Conversation

garas
Copy link
Member

@garas garas commented Mar 6, 2018

  • Plugins were uncategorized on Windows because \ and / mismatch.
  • Include panel missed many included files if they are not app/cake/plugin - add uncategorized files to 'other' group
  • Many includes are from Composer vendor/ directory - add 'vendor' category and group by package
  • Include panel summary displayed incorrect count, because it included count of 'Include Paths'
  • Changed subgroup of app/cake/plugin to lowercase 'other' to be distinct from Controller/Model/... and to be last in list when sorted.

I've tried to add test like $this->assertArrayHasKey('cakephp/chronos', $data['vendor']);, but during test everything (cake/vendor/etc) is inside DebugKit directory, so everything goes into 'plugins -> DebugKit' group.

But in normal app setup, everything goes into correct categories.

{
foreach ($this->_composerPaths as $package => $path) {
if (strstr($file, $path)) {
return $package;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this of type bool?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strstr returns string, but I just copy/pasted code from _isPluginFile .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You return $package, but doc block states bool.

* @return bool
*/
protected function _niceFileName($file, $type)
protected function _niceFileName($file, $type, $name = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for name to be nullable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function gets 2 arguments when $type is app/cake/root, $name is used when type is plugin/vendor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you should fix the doc block.

@dereuromark
Copy link
Member

Nice work!

/**
* The list of Composer packages
*
* @var <type>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type? array

@codecov-io
Copy link

codecov-io commented Mar 6, 2018

Codecov Report

Merging #598 into master will increase coverage by 0.01%.
The diff coverage is 64.86%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #598      +/-   ##
============================================
+ Coverage     51.13%   51.14%   +0.01%     
- Complexity      472      482      +10     
============================================
  Files            47       47              
  Lines          1412     1437      +25     
============================================
+ Hits            722      735      +13     
- Misses          690      702      +12
Impacted Files Coverage Δ Complexity Δ
src/Panel/IncludePanel.php 70.27% <64.86%> (-9.33%) 32 <12> (+10)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bef8127...aebdff2. Read the comment docs.

@@ -156,7 +156,7 @@ protected function _isAppFile($file)
* Check if a path is from a plugin
*
* @param string $file File to check
* @return bool
* @return string|bool plugin name, or false if not plugin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think an is...() method should ever return anything but bool. Why do you need to return the plugin name?
Then it should be called pluginFile() and return null otherwise.

@@ -173,7 +173,7 @@ protected function _isPluginFile($file)
* Check if a path is from a Composer package
*
* @param string $file File to check
* @return bool
* @return string|bool package name, or false if not Composer package
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@markstory markstory added this to the 3.x milestone Mar 6, 2018
@markstory
Copy link
Member

Once the tests are passing this looks pretty good to me.

@garas
Copy link
Member Author

garas commented Mar 6, 2018

Tests are failing because CakePHP 3.6 deprecations.

Tests on 3.4.0 (PHP: 5.6 PREFER_LOWEST=1) passes.

Fix tests, then I could rebase to re-test on fixed version

@markstory markstory self-assigned this Mar 6, 2018
@markstory
Copy link
Member

My mistake @garas. We have another branch that has no remaining deprecation errors, but it might be some time before that lands on master.

@saeideng
Copy link
Member

saeideng commented Mar 6, 2018

fixed in #599
@garas can you rebase your PR on master?

@garas
Copy link
Member Author

garas commented Mar 8, 2018

I've rebased yesterday, tests passed. You can merge.

@markstory markstory merged commit b5e11f3 into cakephp:master Mar 8, 2018
@garas garas deleted the includes-panel branch March 8, 2018 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants