Skip to content

Conversation

@tobiasKaminsky
Copy link
Member

With this AndroidStudio should use the same code formatting for everyone.
Ref: #3320 (comment)

@AndyScherzinger can you test if this does the following:

package com.owncloud.android;
import lombok.Getter;
import lombok.Setter;
public class CodeFormatting {
    @Getter @Setter private String test; // this has to be done manually
    private void loop() {
        for(int i=0;i<10;i++)System.currentTimeMillis();

		boolean b;
        if(System.currentTimeMillis()>10)b=true;

        while(System.currentTimeMillis()>10)System.currentTimeMillis();
    }
}

should change after Alt+Shift+L (Reformat Code) to

package com.owncloud.android;

import lombok.Getter;
import lombok.Setter;

public class CodeFormatting {
    @Getter @Setter private String test; // this has to be done manually, but it keeps the way

    private void loop() {
        for (int i = 0; i < 10; i++) {
            System.currentTimeMillis();
        }

		boolean b;
        if (System.currentTimeMillis() > 10) {
            b = true;
        }

        while (System.currentTimeMillis() > 10) {
            System.currentTimeMillis();
        }
    }
}
  • correct new lines
  • braces around one liner if/for/while

Signed-off-by: tobiasKaminsky [email protected]

Signed-off-by: tobiasKaminsky <[email protected]>
@nextcloud-android-bot
Copy link
Collaborator

Lint

TypemasterPR
Warnings8585
Errors

FindBugs (new)

Warning TypeNumber
Bad practice Warnings35
Correctness Warnings162
Internationalization Warnings15
Malicious code vulnerability Warnings10
Multithreaded correctness Warnings9
Performance Warnings120
Security Warnings204
Dodgy code Warnings135
Total690

FindBugs (master)

Warning TypeNumber
Bad practice Warnings35
Correctness Warnings162
Internationalization Warnings15
Malicious code vulnerability Warnings10
Multithreaded correctness Warnings9
Performance Warnings120
Security Warnings204
Dodgy code Warnings135
Total690

@tobiasKaminsky tobiasKaminsky mentioned this pull request Dec 7, 2018
@AndyScherzinger
Copy link
Member

I gave it a try while during import AS is simply removing all the formatting config changes introduced in this PR.

@mario
Copy link
Contributor

mario commented Dec 13, 2018

Should you really be importing though @AndyScherzinger ? Or just opening?

@AndyScherzinger
Copy link
Member

Hmmm, well I just opened the project since due to the AS files AS is detecting it as a Android Project right away. So yes, I am just opening it.

@tobiasKaminsky
Copy link
Member Author

This also does not work for me :/
There is a https://www.jetbrains.com/help/idea/settings-tools-settings-repository.html, but this also does not work for me, when I am trying it locally…

@codecov
Copy link

codecov bot commented Jan 23, 2019

Codecov Report

Merging #3325 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff            @@
##             master   #3325   +/-   ##
========================================
  Coverage      6.16%   6.16%           
  Complexity        1       1           
========================================
  Files           317     317           
  Lines         30516   30516           
  Branches       4389    4389           
========================================
  Hits           1882    1882           
+ Misses        28349   28348    -1     
- Partials        285     286    +1
Impacted Files Coverage Δ Complexity Δ
.../third_parties/daveKoeller/AlphanumComparator.java 82.14% <0%> (ø) 0% <0%> (ø) ⬇️

@tobiasKaminsky
Copy link
Member Author

So I gave it a new try

  • complete new clone from this repo
  • close all projects in AS
  • in this screen I used "open an existing Android Studio project"
    image
  • c&p code sample from first post
  • Code -> Reformat Code
  • seems to work

@AndyScherzinger
Copy link
Member

@tobiasKaminsky let's merge it then :)

@AndyScherzinger AndyScherzinger merged commit 4ab17b5 into master Mar 22, 2019
@AndyScherzinger AndyScherzinger deleted the codeFormatting branch March 22, 2019 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants