Custom Coding Standard for PHP_CodeSniffer in PhpStorm - phpstorm

I'm using PHP_CodeSniffer via command line already, respecting my custom rule set located in the project root at .phpcs.xml
Now I'm trying to integrate the sniffer as inspection in PhpStorm.
First, I had to add /private to my Docker shared directories
Settings -> Languages & Frameworks -> Quality Tools has option By default project interpreter set. In the configuration for PHP_CodeSniffer, the paths to phpcs and phpcbf have been specified & validated
Settings - Editor -> Inspecions -> PHP_CodeSniffer validation has been enabled.
When I select e.g. PSR-12 as coding standard, the inspections seem to work.
How can I get my custom .phpcs.xml instead? Trying to select Custom and provide the absolute path to my file returns error:
phpcs: ERROR: the "<path>/.phpcs.xml" coding standard is not installed. The installed coding standards are MySource, PEAR, PSR1, PSR12, PSR2, Squiz and Zend
I'm using latest version of PhpStorm (2020.3.2), PHP_CodeSniffer 3.5.8
I hope someone could tell where things are going wrong.

Related

PhpStorm doesn't type hint magic constants

I just installed PhpStorm 2020.2.1 and while type hinting works for classes imported via "use", many built-in PHP classes and constants, such as __NAMESPACE__, __DIR__ and the PDO class appear as undefined in the IDE.
I tried invalidating cache and checked settings -> Languages & Frameworks -> PHP Runtime , and even reinstalled PhpStorm, but code that causes no warnings on my colleguaes' IDEs still flag as undefined in mine.
You have some issue with PhpStorm caches on your system (quite a few people do for some reason, mainly those that had previous version) as it works just fine here.
Sadly built-in cache invalidation does not help here and you need to do this manually:
Close IDE.
Using your file manager, go to the caches folder for this IDE version and delete it. Typical folder locations:
Windows: %USERPROFILE%\AppData\Local\JetBrains\PhpStorm2020.2\caches
Linux: ~/.cache/JetBrains/PhpStorm2020.2/caches
macOS: ~/Library/Caches/JetBrains/PhpStorm2020.2/caches
If you have installed your IDE using Toolbox App then the folder location might be different (the exact path then can be found from idea.log file (Help | Show Log in XXX) or perhaps from Toolbox App (look for appropriate options under the "gear" icon for PhpStorm).
Launch IDE, open project and let it re-index the whole thing again.
The ticket to watch after (if you are interested): https://youtrack.jetbrains.com/issue/WI-54626 -- watch it (star/vote/comment) to get notified on any progress.

How do I correctly start using .readthedocs.yml

I have a basic ReadTheDocs repository. As per the advice of the build page, I sought to use a .readthedocs.yml to configure it:
Configure your documentation builds! Adding a .readthedocs.yml file to your project is the recommended way to configure your documentation builds. You can declare dependencies, set up submodules, and many other great features.
I added a basic .readthedocs.yml:
version: 2
sphinx:
builder: dirhtml
fail_on_warning: true
and got a build failure:
Problem in your project's configuration. Invalid "sphinx.builder": .readthedocs.yml: Your project is configured as "Sphinx Html" in your admin dashboard, but your "sphinx.builder" key does not match.
This was surprising as it seemed contrary to the guidance in the admin dashboard at https://readthedocs.org/dashboard/PROJECTNAME/advanced/ which led me to assume that I could set whatever I liked in the admin dashboard, but it would be overridden by my .readthedocs.yml (which is the behaviour I expected and wanted):
These settings can be configured using a configuration file. That's the recommended way to set up your project. Settings in the configuration file override the settings listed here.
I updated the setting in the admin dashboard to match the .readthedocs.yml and then got a build error:
Sphinx error:
master file /home/docs/checkouts/readthedocs.org/user_builds/PROJECT_NAME/checkouts/latest/source/contents.rst not found
which looks like https://github.com/readthedocs/readthedocs.org/issues/2569 (RTD not finding Sphinx configuration) - but it's not clear why that's happening because prior to adding .readthedocs.yml, the project built just fine.
I'm struggling to model what's actually going on here:
The config file isn't acting as an "overlay" / "override" onto the web settings - as per the first error, some forms of disagreement are a build failure
It's almost like if the config file exists, the web config is ignored - this would explain the contents.rst issue arising, but this isn't consistent with the first error
Adding a python.install entry to .readthedocs.yml eventually got the site building, but it's still not clear to me if I'm generally doing the right thing, and/or how successful future config changes will be.
The reason you're getting the error is that the sphinx version you're using locally doesn't match with the version readthedocs is using at the time you initiated the build process.
See here: You can use a requirements.txt file to use the same version of sphinx you use locally. I had the same issue. I've solved it by simply adding my version Sphinx==3.1.2
Also, I added a .readthedocs.yml file in my project directory where docs/ resides, pointing to where the conf.py because
I was using an extension sphinxcontrib.napoleon which readthedocs build process fails to recognize.
Wanted readthedocsbuild process to use a specific version on Sphinx.
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 1
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml
# Optionally build your docs in additional formats such as PDF
formats:
- pdf
# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt
a
and added all the dependencies needed to generate the documentation in docs/requirement.txt
Babel==2.8.0
imagesize==1.2.0
readme-renderer==26.0
Sphinx==3.1.2
sphinx-argparse==0.2.5
sphinx-rtd-theme==0.5.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-images==0.9.2
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-napoleon==0.7
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4

Can't execute setup.py (Error 5 - Access Denied)

I ran into a problem creating a new project in Cocos2d-x 3.1.1 (or 3.0 - it happens at both versions).
When I'm running the build script in console (Windows 8 - console with admin privileges) an WindowsError pops up (check the image below).
http://i.imgur.com/Ixg4jEE.png
I can set up the COCOS_CONSOLE_ROOT manually, but it does not help with the Error 5.
I tried setting the 777 priviligies an all cocos2d-x folder and subfolders, but it does not help.
Anybody had the same problem? Any solutions out there?
On Windows you should not put manually installed programs and tools under C:\Program... (english: C:\Program Files) because that's a folder where only apps with a proper installer should go. Otherwise you will keep having permission issues. Apps are not allowed to write to that folder or any of its subfolders.
Since cocos2d-x isn't an app, it can't redirect its output to the proper AppplicationData folder as is mandated by the operating system. Not being able to write or modify the program folder's contents (except during installation) is a security feature in Windows that you can't (or shouldn't) bypass.
To fix this simply extract cocos2d-x in a folder that both you and apps have full read/write permission. Normally this would be in your Documents folder, but Desktop would also work and probably just any folder on a drive that you created, for instance C:\cocos2d-x.
Due to this line:
_winreg.SetValueEx() ...
the actual problem looks like to be with registry access, rather than with file permissions.
Make sure you actually running console as an admin, by:
searching cmd in Windows search, or just creating a shortcut to it to desktop
right clicking to cmd.exe and choosing "Run as administrator"
Make sure you don't have registry access block in any way: like blocking in group policies, some "security optimization" software and viruses and antiviruses.
Make sure your python version is 2.x. Python 3.x is not supported.
Anyway, this 'setup.py' step is optional for using cocos2d-x and you can live without running it at all.

Using mergJSON in a LiveCode Standalone - no functionality?

I'm using the mergJSON external in LiveCode and all is working fine in the IDE but not in the standalone application.
I use LiveCode 6.0.1 Community Edition for Mac OSX 10.8.3 with mergJSON (https://github.com/montegoulding/mergJSON)
When I create a standalone application (Mac) the mergJSON functionality doesn't seem to exist any more. There are no errors messages, simply that nothing works.
I have a button that grabs a piece of JSON data, converts it into a LiveCode array and populates a DataGrid. This works fine in the IDE. It does nothing when I press it in the standalone application.
Stand alone generator settings
LiveCode > Standalone Settings > Select Inclusions
should make sure that for the standalone application the mergJSON script libraries are visible, which they are. Currently I'm using "Search for required inclusions when saving the standalone..." option the Standalone Settings.
Anyone have any suggestions?
Thanks,
Steve
Have you followed this tutorial on setting up the user extensions folder for a third party extension. Note that the standalone builder will show an external if it's in the Externals folder but look for it in the Runtime folder so you need to add it there too.
http://lessons.runrev.com/s/lessons/m/4071/l/6347-how-to-install-3rd-party-externals-for-use-in-the-ide-and-standalone-builder
Also note that there's no Universal or PowerPC build so you need to build your app for x86 only.

In monodevelop, how to set the working directory when running your code

does anyone know if it is possible to set the working directory for running the application you create in monodevelop?
The app is written to the bin/Debug directory and that seems to be the working directory when you debug the application. For my application (which I am porting from Windows) it takes an XML configuration file which references other XML files, the paths (in the configuration xml) I use are relative paths (which is sensible imo).
IIRC Visual Studio lets you set the working directory when you are debugging, does monodevelop? I had a good look around the options and tried to search for an answer, but no luck.
thanks
Dave
As far as I'm aware "Run" and "Debug" mode use the same working directory.
Have a look at the following post