benmatselby / sublime-phpcs

🔍 PHP CodeSniffer, PHP Coding Standard Fixer, Linter, and Mess Detector Support for Sublime Text
Other
814 stars 126 forks source link

TypeError: sequence item 0: expected str instance, list found #142

Closed ghost closed 9 years ago

ghost commented 9 years ago

The result with running PHP Code Sniffer:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 556, in run_
    return self.run(edit)
  File "phpcs in /Users/lo/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 649, in run
  File "phpcs in /Users/lo/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 465, in run
  File "phpcs in /Users/lo/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 143, in get_errors
  File "phpcs in /Users/lo/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 421, in execute
  File "phpcs in /Users/lo/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 424, in parse_report
  File "phpcs in /Users/lo/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 150, in shell_out
TypeError: sequence item 0: expected str instance, list found

My settings:

  1. OS X v10.11
  2. Sublime Text 3 Build 3083
  3. I have installed all tools that required sublime phpcs official website.
installed:
  fabpot/php-cs-fixer          v1.10  A tool to automatically fix PHP code style
  pdepend/pdepend              2.2.1  Official version of pdepend to be handl...
  phpmd/phpmd                  2.3.2  PHPMD is a spin-off project of PHP Depe...
  sebastian/diff               1.3.0  Diff implementation
  squizlabs/php_codesniffer    2.3.4  PHP_CodeSniffer tokenizes PHP, JavaScri...
  symfony/config               v2.7.5 Symfony Config Component
  symfony/console              v2.7.5 Symfony Console Component
  symfony/dependency-injection v2.7.5 Symfony DependencyInjection Component
  symfony/event-dispatcher     v2.7.5 Symfony EventDispatcher Component
  symfony/filesystem           v2.7.5 Symfony Filesystem Component
  symfony/finder               v2.7.5 Symfony Finder Component
  symfony/process              v2.7.5 Symfony Process Component
  symfony/stopwatch            v2.7.5 Symfony Stopwatch Component
  1. All tools are set executable_path: scheck, phpcs, phpmd, phpcbf, php_cs_fixer, phpcs_php_path

Below is the php code when I test with PHP Code Sniffer:

<?php
echo 'a';
?>

I don't believe this result.

benmatselby commented 9 years ago

Hi there, can you please turn on show_debug = true and provide me with all of your settings please and the full debug output when running the plugin..

ghost commented 9 years ago

Below is an output when I run 'sniff this file': (turn on show_debug = true, but same)

Exception in thread Thread-26:
Traceback (most recent call last):
  File "./threading.py", line 901, in _bootstrap_inner
  File "./threading.py", line 858, in run
  File "phpcs in /Users/lo/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 474, in run
  File "phpcs in /Users/lo/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 143, in get_errors
  File "phpcs in /Users/lo/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 421, in execute
  File "phpcs in /Users/lo/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 424, in parse_report
  File "phpcs in /Users/lo/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 150, in shell_out
TypeError: sequence item 0: expected str instance, list found

Below is my phpcs.sublime-settings:

{
    "show_debug": false,

    "scheck_executable_path":
    [
        "/opt/pfff/scheck"
    ],

    "phpcs_executable_path":
    [
        "/Users/lo/.composer/vendor/squizlabs/php_codesniffer/scripts/phpcs"
    ],

    "phpmd_executable_path":
    [
        "/Users/lo/.composer/vendor/phpmd/phpmd/src/bin/phpmd"
    ],

    "phpcbf_executable_path":
    [
        "/Users/lo/.composer/vendor/phpcbf"
    ],

    "php_cs_fixer_executable_path":
    [
        "/Users/lo/.composer/vendor/php-cs-fixer"
    ],

    "phpcs_php_path":
    [
        "/Users/lo/Sites/hello/"
    ],
}

Below is my .composer/composer.json:

{
    "require": {
        "squizlabs/php_codesniffer": "*",
        "pdepend/pdepend": "2.2.1",
        "fabpot/php-cs-fixer": "^1.10"
    },
    "require-dev": {
        "phpmd/phpmd": "@stable"
    }
}

Below is my .composer/vendor/:

autoload.php    composer    pdepend     sebastian   symfony
bin     fabpot      phpmd       squizlabs
benmatselby commented 9 years ago

@demavend Can you provide the output from the debug before the stack trace please, so I can see what commands are being run etc?

ghost commented 9 years ago
startup, version: 3083 osx x64 channel: stable
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/lo/Library/Application Support/Sublime Text 3/Packages
state path: /Users/lo/Library/Application Support/Sublime Text 3/Local
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/lo/Library/Application Support/Sublime Text 3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.269979
using gpu buffer for window
startup time: 0.360197
first paint time: 0.379039
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_file_settings
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.quick_panel
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.02-bz2
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin Phpcs.phpcs
reloading plugin SideBarEnhancements.SideBar
reloading plugin SideBarEnhancements.SideBarAPI
reloading plugin SideBarEnhancements.SideBarDefaultDisable
plugins loaded
Package Control: Installing 1 upgrades
ignored packages updated to: ["SideBarEnhancements", "Vintage"]
reloading Packages/SideBarEnhancements/Side Bar.sublime-settings
unloading plugin SideBarEnhancements.SideBar
unloading plugin SideBarEnhancements.SideBarAPI
unloading plugin SideBarEnhancements.SideBarDefaultDisable
reloading Packages/User/Package Control.sublime-settings
reloading Packages/User/Preferences.sublime-settings
Package Control: Upgraded SideBarEnhancements to 2015.10.11.02.01.59
ignored packages updated to: ["Vintage"]
reloading Packages/SideBarEnhancements/Side Bar.sublime-settings
reloading plugin SideBarEnhancements.SideBar
reloading plugin SideBarEnhancements.SideBarAPI
reloading plugin SideBarEnhancements.SideBarDefaultDisable
reloading Packages/User/Package Control.sublime-settings
reloading Packages/User/Preferences.sublime-settings
reloading Packages/User/Preferences.sublime-settings
benmatselby commented 9 years ago

@demavend HI there, this still isn't giving me the commands you are running. I am expecting to see some debug/output with [Phpcs] in it.

ghost commented 9 years ago

How to debug Phpcs and see output?

benmatselby commented 9 years ago

Hi @demavend

Sublime Text > Preferences > Package Settings > PHP Code Sniffer > Settings - User

And have at the very least:

{
    "show_debug": true,
}

But I think you already have settings in there, so just simply add the show_debug bit.

Then open the console, which you have done already, run the plugin (in whatever way you do that) and then you will get debug that shows you the exact commands being shelled out to the console.

ghost commented 9 years ago

It's same again. thank you. I'll just give up maybe.

benmatselby commented 9 years ago

Without seeing what commands are being run, it's going to be hard to help fix it I am afraid. It simply could be a config issue.

fonkyju commented 9 years ago

Hi, I have the same problem.

You can see my debug [Phpcs] php -l -d display_errors=On /Users/julien/Sites/www/project/application/frontend/controllers/access.php [Phpcs] php -l -d display_errors=On /Users/julien/Sites/www/project/application/frontend/controllers/access.php [Phpcs] cwd: /Users/julien [Phpcs] No syntax errors detected in /Users/julien/Sites/www/project/application/frontend/controllers/access.php

[Phpcs] phpcs --report=checkstyle --standard=PSR2 -n /Users/julien/Sites/www/project/application/frontend/controllers/access.php [Phpcs] phpcs --report=checkstyle --standard=PSR2 -n /Users/julien/Sites/www/project/application/frontend/controllers/access.php [Phpcs] cwd: /Users/julien Traceback (most recent call last): File "/Applications/Sublime Text.app/Contents/MacOS/sublimeplugin.py", line 556, in run return self.run(edit) File "phpcs in /Users/julien/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 649, in run File "phpcs in /Users/julien/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 467, in run File "phpcs in /Users/julien/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 143, in get_errors File "phpcs in /Users/julien/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 219, in execute File "phpcs in /Users/julien/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 222, in parse_report File "phpcs in /Users/julien/Library/Application Support/Sublime Text 3/Installed Packages/Phpcs.sublime-package", line 173, in shell_out File "./subprocess.py", line 824, in init File "./subprocess.py", line 1448, in _execute_child FileNotFoundError: [Errno 2] No such file or directory: 'phpcs'

When I execute the command (phpcs --report=checkstyle --standard=PSR2 -n /Users/julien/Sites/www/project/application/frontend/controllers/access.php) in a terminal, I have no problem and I get the error list.

My sublime config file

{ "auto_complete": true, "bold_folder_labels": true, "color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme", "draw_minimap_border": false, "extensions_to_blacklist": [ ], "extensions_to_execute": [ "php", "inc" ], "find_selected_text": false, "font_size": 16, "gutter": true, "highlight_line": true, "ignored_packages": [ "Vintage" ], "line_padding_bottom": 1, "match_brackets": true, "match_brackets_angle": false, "match_brackets_braces": true, "match_brackets_content": true, "match_brackets_square": true, "php_cs_fixer_additional_args": { }, "php_cs_fixer_executable_path": "/usr/local/php5/bin/php-cs-fixer", "php_cs_fixer_on_save": false, "php_cs_fixer_show_quick_panel": true, "phpcbf_additional_args": { "--standard": "PSR2", "-n": "" }, "phpcbf_executable_path": "/usr/local/php5/bin/phpcbf", "phpcbf_on_save": false, "phpcbf_show_quick_panel": true, "phpcs_additional_args": { "--standard": "PSR2", "-n": "" }, "phpcs_command_on_save": false, "phpcs_executable_path": "/usr/local/php5/bin/phpcs", "phpcs_execute_on_save": false, "phpcs_icon_scope_color": "comment", "phpcs_linter_command_on_save": false, "phpcs_linter_regex": "(?P.*) on line (?P\d+)", "phpcs_linter_run": true, "phpcs_outline_for_errors": true, "phpcs_php_path": "/usr/local/php5/bin/php", "phpcs_show_errors_in_status": true, "phpcs_show_errors_on_save": true, "phpcs_show_gutter_marks": true, "phpcs_show_quick_panel": true, "phpcs_sniffer_run": true, "phpmd_additional_args": { "codesize,unusedcode,naming": "" }, "phpmd_command_on_save": false, "phpmd_executable_path": "/usr/local/php5/bin/phpmd", "phpmd_run": true, "save_on_focus_lost": true, "scheck_additional_args": { "-strict": "" }, "scheck_command_on_save": false, "scheck_executable_path": "", "scheck_run": false, "scroll_past_end": true, "show_debug": false, "tab_size": 4, "translate_tabs_to_spaces": true }

Is there a config error ?

Thanks.

benmatselby commented 9 years ago

@fonkyju

Aye, please see the troubleshooting guide - You basically need to set the path you your PHPCS application

fonkyju commented 9 years ago

I've already see the troubleshooting page.

As you can see in my config, I have set all the path

"php_cs_fixer_executable_path": "/usr/local/php5/bin/php-cs-fixer", "phpcbf_executable_path": "/usr/local/php5/bin/phpcbf", "phpcs_executable_path": "/usr/local/php5/bin/phpcs", "phpmd_executable_path": "/usr/local/php5/bin/phpmd",

Moreover all theses applications are in my PATH but it doesn't work with blank path like "phpcs_executable_path": "".

benmatselby commented 9 years ago

@fonkyju The config you mention is not reflected in your console output though I'm afraid. If

"phpcs_executable_path": "/usr/local/php5/bin/phpcs",

Was being used this line:

[Phpcs] phpcs --report=checkstyle --standard=PSR2 -n /Users/julien/Sites/www/project/application/frontend/controllers/access.php

Would actually be:

[Phpcs] /usr/local/php5/bin/phpcs --report=checkstyle --standard=PSR2 -n /Users/julien/Sites/www/project/application/frontend/controllers/access.php

Moreover all theses applications are in my PATH but it doesn't work with blank path like "phpcs_executable_path": "".

Sublime Text generally does not look at your PATH, which is why we have to define them in ST

fonkyju commented 8 years ago

And so you see what's going wrong ?

Thanks

benmatselby commented 8 years ago

Yes, your configuration is incorrect, but unsure why. Is the configuration in the right file and in the right format:

http://benmatselby.github.io/sublime-phpcs/#configuration