Scratches being considered part of the Project with Problems and Safe Delete?!

This is mystifying, but Scatches and Consoles files and folders appear to be being considered part of the "project" enough that empty scratch.json files there will show up in the Problems tab with an error, when it shouldn't care at all about anything there:

Double-clicking the error opens up the empty scratch.json file, with the same validation (inspection?) error:

I don't care if files in Scratches and Consoles have invalid code in them... they're just used for formatting text from non-code sources (like testing output or tutorial examples) or for my own notes. I save all kinds of files in there, .txt, .log, .debug, .sql, you name it. It's just a digital notepad for me with PHPStorm's convenient formatting and Favorites bookmark across projects!

When I go to delete a file using right-click, I can only select Safe Delete... which then has a checkbox to search for anything using that file... but they're not code files, they're not in the project directory, and so having to go through these steps are extraneous, and accidentally deleting references could screw up my project when there's never any reason for this to be connected this way to begin with!

This should be really simple, but it's now overly-complicated. How do I tell PHPStorm to keep Scratches and Consoles not part of indexing or Inspections or safe delete or Problems or any considerations regarding code functionality?!

15 comments
Comment actions Permalink

Hm, do you see the scratch file when you run an Inspection Check for the whole project?

As for the "Safe delete" option, I have just tested in on my setup and may confirm that scratch files are not referenced with the rest of the project. In other words, for example, the variable defined in a reference file will not be "seen" in other project files and vice versa, so it should be safe to delete it.

0
Comment actions Permalink

I clicked Code > "Inspection Check" (Windows):

It takes a long while...

I get a low memory error on a 32GB RAM computer:

When it finishes, it's really hard to tell if there's any empty json errors... but I'm not seeing any anywhere.

So, I don't know; which would that "empty json" error appear in anyway?

0
Comment actions Permalink

Seems like JSON parser does not like empty JSON files/content at all. Since this error comes from a low level parse/lexer, it will not be shown in Inspection results (unless such support is added).

Related: https://youtrack.jetbrains.com/issue/WEB-36741#focus=Comments-27-3254804.0-0

This will happen even in the following code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script type="application/ld+json">
</script>
</body>
</html>

 

0
Comment actions Permalink

Hi, I'm on Mac now and keep getting Scratches and Consoles files showing up in things like suggestions and auto-completion and definition tracing etc... I think I have another forum post here about it (somewhere 😬) but this is probably stemming from the same issue.

On Mac, I don't have a `Code > Inspection Check`, though I do have `Code > Inspect Code...`... is that the same thing?

The other options below that don't seem relevant to this.

Before this year, I think I've never seen Scratches and Consoles files show up in any way when it came to indexing or inspection or suggestion or autocomplete or tracing... it's strange this became a problem this year, and I just can't tell if it's because of an update or a bug or I'm doing something wrong.

I know I probably shouldn't be using Scratches and Consoles for scratch file notes etc 😆 but it's so convenient because I can just have it in a PHPStorm panel (Favorites) and the editor is so good with text in different kinds of files (Windows is good with Notepad++ but Mac doesn't have an equivalent as good as either, though TextMate comes pretty close, it's still annoying to use compared to PHPStorm).

I hope all of this is making clear sense.

0
Comment actions Permalink

On Mac, I don't have a `Code > Inspection Check`, though I do have `Code > Inspect Code...`... is that what I should try to see how PHPStorm could be considering the non-repo folder part of inspection (or indexing?) code?

Yes, "Code | Inspect Code..." to run all enabled/applicable inspections or "Code | Analyze Code | Run Inspection by Name..." if you want to run specific inspection only.

0
Comment actions Permalink

Thanks. Why are they named differently in Windows and Mac? I can see why Settings and Preferences would be, but not "Inspection Check" and "Inspect Code".

Do you think that PHPStorm thinks Scratches and Consoles are "test sources"?

I'm going to uncheck it for the test; as far as I know, the project's test sources are in the `test` folder which I've already marked as a "Test" folder.

0
Comment actions Permalink

There's no "Inspection Check" on Windows. You've probably misread this.

So, where exactly scratches & console show up? You're saying "everywhere" but that's not something I'm seeing, and not something being reported on our tracker. So I'd appreciate an example or two.

-1
Comment actions Permalink

Dmitry, I didn't say Scratches & Consoles showed up "everywhere". I said that PHPStorm is considering Scratches & Consoles in the Problems tab (which it shouldn't, because it's not part of the repo), in each of its file's right-click Delete (checking for relations in repo files, which would be completely irrelevant and may possibly cause unwanted repo file changes), suggestions and auto-completion and definition tracing while in repo files (so that if I Cmd+click a function call it'll show or go to a definition result from an S&C file)... I'm sure there's other things I've forgotten or not aware of, but essentially it's treating S&C like it contains relevant code files related to the project repo files... that's BAD. I don't remember that happening before this year; S&C files were not considered part of the runnable app project code or anything like that. They don't go to the server or remote repo, they won't run on my local server, so they shouldn't be part of tracing or validation etc.

Anyway, to Andriy: Inspect Code apparently has been running all night, is barely halfway through, caused a memory warning, is causing PHPStorm to run extremely slow and laggy, and who knows may take all day to finish, completely making it impossible to do my job.

Is this something that's supposed to be run over the weekend?! I'm not even sure what this will tell me, it seems to be doing way more than I need to figure out why it's considering S&C files part of traceable code.

Vasiliy: Where do I even see if it's parsing S&C files? I don't know when this thing is going to finish or what to open.

0
Comment actions Permalink

@Vadiru

Anyway, to Andriy: Inspect Code apparently has been running all night, is barely halfway through, caused a memory warning, is causing PHPStorm to run extremely slow and laggy, and who knows may take all day to finish, completely making it impossible to do my job.

Just cancel it. It seems that it is run even on 3rd party code files (e.g. AdminLTE)...

1
Comment actions Permalink

Thanks for the clarification and sorry for misreading your initial message. 

I've reported the problem as https://youtrack.jetbrains.com/issue/IDEA-278431 - feel free to vote for it.

0
Comment actions Permalink

Andriy Bazanov I had to cancel it. I wasn't asking if it needs to run all weekend because I was waiting to hear if I should cancel it, I was asking literally if it needs to run all weekend. Is that usual or unusual for it to run all night and only get like 55% through, and give a memory warning? The memory warning at least happened on two completely unrelated projects (one in Laravel 5 and another in Symfony 3) and operating systems (Windows and Mac), so that seems to be normal at this point (which is a bad thing).

So, what am I looking for anyway with your suggestion to run this? I thought we were looking for evidence of where or how PHPStorm considers my Scratches & Consoles part of scannable relatable code when it shouldn't. How do I determine that with or without this scan?

0
Comment actions Permalink

@Vadiru

Is that usual or unusual for it to run all night and only get like 55% through, and give a memory warning?

Never had such issues on my projects (mainly Laravel based; at very least I do not remember seeing anything in the last 3-4 years). It always finishes running it acceptable short time here (max few mins). Although I never run on the WHOLE project -- only on app folder (which is PHP code + Blade views).

So, what am I looking for anyway with your suggestion to run this?

Which one in particular?

My first comment was about "value expected" issue in your initial message.

My second comment was answering your "I do not have Inspection Check" part and nothing more. Perhaps I have selected too much text in my quote which must have confused you. I had no intentions to answer or even touch "why scratches are considered part of the project" here.

0
Comment actions Permalink

Andriy, Vasiliy asked me if I'd done Inspect Code on the whole project... so that's what I did. If you think running inspection will not show me why Scratches & Consoles are being considered by PHPStorm as part of the project, then how am I supposed to solve this problem? I'm tired of having the editor consider that "folder" (?) in the Problems tab, in each of the file's right-click Delete, in suggestions and auto-completion and definition tracing...

What am I supposed to do to find out why it does this?!

This has happened over two PHPStorm installs on different operating systems and a dozen projects all year.. this is a question for ALL OF YOU. 

0
Comment actions Permalink

> I'm tired of having the editor consider that "folder" (?) in the Problems tab

 

Could you please elaborate on this or attach a screenshot?

 

What am I supposed to do to find out why it does this?!

 

Do you mean the problem with the scratches? Then you don't have to do anything, the problem is already acknowledged: https://youtrack.jetbrains.com/issue/IDEA-278431.

0
Comment actions Permalink

Sorry I wrote in a frustrated way.

I added a note to the ticket clarifying that the problem happens not just with the Problems tab, but that the underlying problem affects other things as well... I'm just not sure how to easily demonstrate them, nor what context or state my PHPStorms were in when they happen... they just happen, and it seems to have been since the beginning of this year (though maybe back to October when I started a job) across two jobs using two different operating systems.

I was just frustrated that the problem is broad in scope (because it affects pretty much anything relying on scanning the folders for text) and I didn't want people thinking it only affected one feature. It's a big problem, though thankfully it doesn't happen a lot because I don't have many files that contain code in S&C that matches repo files (like function or class names etc). I have kept backup code files there for comparisons, and that's when the problem surfaces most. I hope what I'm saying is understandable.

0

Please sign in to leave a comment.