The Spark code style requires four character indentation for multi parameter methods. So: the following code -as presently formatted by IJ - is incorrect:
def generateCirclesRdd(sc: SparkContext, nCircles: Int = 3, nTotalPoints: Int = 30, outerRadius: Double): RDD[(Long, Long, Double)] = {
It should apparently be:
def generateCirclesRdd(sc: SparkContext, nCircles: Int = 3, nTotalPoints: Int = 30, outerRadius: Double): RDD[(Long, Long, Double)] = {
Where is this setting in the IJ code style? Screenshot shows what I was able to find.
UPDATE There is a comment about "Tabs and Indents" here it is :
Another Update: @yole has provided a helpful answer. However, I am still left with 2 spaces instead of 4 on the continuation.
For reference, here is the correct/required indentation within Spark. Notice the continuation on method declarations is 4 spaces.
def train( data: RDD[Vector], k: Int, maxIterations: Int, runs: Int, initializationMode: String, seed: Long): KMeansModel = {
However the continuation on method invocations is only two:
new KMeans().setK(k) .setMaxIterations(maxIterations) .setRuns(runs) .setInitializationMode(initializationMode) .setSeed(seed) .run(data)
In the editor, select a code fragment you want to reformat. Before reformatting, you can take a look at the code style settings that are applied to the selected code: press Alt+Enter and click Adjust code style settings. From the main menu, select Code | Reformat Code or press Ctrl+Alt+L .
Open indentation settings in code style scheme Click the widget and select Configure Indents for 'Language'. In the dialog that opens, you can change settings for tabs and indents and also configure other code style settings. Click OK. Reformat the necessary part of your project to apply new indentation settings.
IDEA has a “smart tabs” option that you can turn on: If this check box is selected, IntelliJ IDEA inserts tabs for indentation and reformatting, but fine alignment to a necessary column is done only via spaces. This is done in order to preserve visual representation of the source code, when the Tab Size is changed.
Press Ctrl+Alt+S to open the IDE settings and select Editor | Code Style. and select Import Scheme. Then select the necessary format. In the dialog that opens, select the file with the settings and click Open.
Uncheck "Method declaration parameters | Align when multiline" and enable "Use normal indent for parameters".
There is two option that you have to change
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With