Rider automatically formats List initializer to not contain spaces causing compilation errors - rider

When I write following code in Rider:
new List<Guid> { Guid.NewGuid() } and I type ; at the end, Rider automatically formats this into new List<Guid> {Guid.NewGuid()};
Note that spaces were removed before and after both braces.
Compiler doesn't like it and reports [SA1012] Opening brace should be followed by a space. and [SA1013] Closing brace should be preceded by a space.
How can I turn off such behavior in Rider?

I don't know which version of Rider you're using but in 2022.2.3 I had to enable the following property under File | Settings | Editor | Code Style | C#:
I hope it helps you as well!

Related

Unexpected whitespace between function name and paren.(func-call-spacing), A space is required before '}'.(object-curly-spacing), webstorm quasar vue

I'm new to using stackoverflow and using WebStorm quasar,and vuejs, so let me know if you need any more details or if I did something wrong.
pictures of code errors:
https://drive.google.com/drive/folders/13oSjnK6Q21ztsihbcF0a-TUUAWAo0vcW?usp=sharing
errors:
ESLint: A space is required after '{'.(object-curly-spacing)
enter image description here
ESLint: Unexpected whitespace between function name and paren.(func-call-spacing)
I correct these errors by adding the correct spacing, but whenever I refresh the website, I'm working on, WebStorm changes them back.
I believe its some sort of a formatting error.
I've gone into,
Settings->Editor->Code Style -> JavaScript
Settings->Editor->Code Style -> TypeScript
and clicked on spaces, and check the appropriate boxes.
spaces - before parenthesis - function call parenthesis
spaces - within - object literal braces
but the problem still persists.
You should have disabled the Spaces > Before parentheses > Function call parentheses and enabled the Within > ES6 Import/Export Braces in Settings | Editor | Code Style | JavaScript; please also make sure that you don't have the IDE code style preferences overwritten by the settings in project .editorconfig (if any)

IntelliJ IDEA: is there a way to format java code in a canonical way?

I have two java source files. Both represent the same class (semantically), but they were formatted differently.
For example, one of them contains the following line:
return Boolean.valueOf(Boolean.getBoolean("abc"));
While in the second file it looks like 2 lines:
return Boolean.valueOf(
Boolean.getBoolean("abc"));
In both cases, when I apply formatting (Ctrl+Alt+L), these lines do not change.
Is it possible to format them in some canonical way: that is, to get the same code if the only difference is formatting?
Equivalently: is there any way to remove all ignorable whitespace? Such a 'dried-out' program would then be easily restored using 'Reformat code'.
You should be able to do this if you turn off "Wrapping and Braces | Keep when reformatting | Line Breaks" in the Java code style settings.
Go to File > Settings > Ediotor > Code Style > java
in tab Wrapping and Braces uncheck line breaks
Apply and make (Ctrl+Alt+L) again.

How do I stop SQL splitting string literals when I press Enter in DataGrip or IntelliJ Database Editor?

When my cursor is after an open quote in a SQL statement in an IntelliJ database console and I press Enter, it closes the quote on the current line and adds a concatenation symbol with an open quote on the newline.
I disabled formatting the SQL code style settings but that didn't fix it for me.
UPDATE blah SET blah2 = 'something<pressed enter>' ||
'<argh!>...';
Is there a way to disable this autoformatting?
This request was addressed in 2017.1 version, as a result, Insert string concatenation on Enter setting was added specifically for SQL:
This can be archived since IntelliJ 13. You simply need to wrap your code with
// #formatter:off
your code goes here
// #formatter:on
Since IntelliJ Idea 15-16(pardon if i'm wrong), you can also make permanent set up by Preferences > Editor > Code Style option
Hope it helps

IntelliJ Align arguments to opening parenthesis?

When I split arguments onto multiple lines in IntelliJ, it puts the argument at a slight indent from the line above. For example:
ClassName.staticMethod(argument1,
argument2,
argument3);
Quick, what are the arguments above? Okay, that's easy because of the example names I chose, but how about below? Which arguments are going to staticMethod below?
ClassName.staticMethod(this.instanceMethod(argument1,
argument2),
argument3);
staticMethod is taking the results of a call to instanceMethod and argment3, but with IntelliJ's default formatting, at a glance you'd completely miss the fact that argument2 is an argument for instanceMethod, not staticMethod.
This is a freaking terrible default behavior. How can I get it to properly line arguments up, as in the modified examples below?
ClassName.staticMethod(argument1,
argument2,
argument3);
ClassName.staticMethod(this.instanceMethod(argument1,
argument2),
argument3);
Settings | Editor | Code Style | Java | Wrapping and Braces | Method call arguments | [x] Align when multiline

Extra space after Join Lines in IntelliJ

IntelliJ IDEA 13.0.1, 13.0.2 (but probably applies to earlier/later versions too)
Consider the following:
Collections.addAll(
new ArrayList<Object>(),
new Object());
I do "Join Lines" since it will fit on one line:
Collections.addAll( new ArrayList<Object>(), new Object());
// ^ space is annoying ^ space is nice
"Join Line" adds an extra space between the current and next line. It makes sense for some lines, but the space before the first parameter has always bugged me.
My workaround is to select and "Reformat Code", but I don't want to do the extra step if I don't have to.
Is there a better way to make "Join Line" not add that first space?
Notes:
Edit > Join Lines
Mac OS X: ⌃⇧J
Windows: Ctrl+Shift+J
Code > Reformat Code
Mac OS X: ⌥⌘L
Windows: Ctrl+Alt+L
I suspect you have a non default formatting set. Try:
File -> Settings -> Code Style -> Java -> Spaces and uncheck Method call parantheses.
This appears to be a bug in the Code Style settings.
The bug appears—for both method declarations and calls—if you modify the Default Scheme and check the following settings:
Code Style > Java > Wrapping and Braces
+- Method declaration parameters
| \- New line after '('
\- Method call arguments
\- New line after '('
Also, there needs to be more than one parameter in the method declaration or call.
Here is the issue in JetBrains' YouTrack.