patrickfav/uber-adb-tools

View on GitHub

Showing 67 of 87 total issues

Method iterateDevices has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    private static Commons.IterationResult iterateDevices(List<AdbDevice> devices, AdbLocationFinder.LocationResult adbLocation, Arg arguments,
                                                          CmdProvider cmdProvider, UserPromptHandler promptHandler, boolean preview) throws Exception {
        Commons.ActionResult actionResult = new Commons.ActionResult();

        if (preview && (arguments.dryRun || arguments.force || arguments.mode == Arg.Mode.BUGREPORT || arguments.mode == Arg.Mode.FORCE_STOP
Severity: Minor
Found in src/main/java/at/favre/tools/uberadb/AdbTool.java - About 6 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method execute has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    static Commons.ActionResult execute(Arg arguments, CmdProvider cmdProvider, AdbLocationFinder locationFinder, UserPromptHandler promptHandler) {
        Commons.ActionResult result = null;

        try {
            AdbLocationFinder.LocationResult adbLocation = locationFinder.find(cmdProvider, arguments.adbPath);
Severity: Minor
Found in src/main/java/at/favre/tools/uberadb/AdbTool.java - About 4 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method find has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public LocationResult find(CmdProvider cmdProvider, String customPath) {
        String osName = System.getProperty("os.name").toLowerCase();

        if (customPath != null && new File(customPath).exists() && cmdProvider.canRunCmd(new String[]{customPath})) {
Severity: Minor
Found in src/main/java/at/favre/tools/uberadb/AdbLocationFinderImpl.java - About 4 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method parseDeviceLine has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    static AdbDevice parseDeviceLine(String line) {
        char[] chars = line.replace("\t", " ").toCharArray();
        StringBuilder deviceName = new StringBuilder();
        String additionalInfo = null;

Severity: Minor
Found in src/main/java/at/favre/tools/uberadb/parser/AdbDevicesParser.java - About 4 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method execute has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public static void execute(AdbLocationFinder.LocationResult adbLocation, Arg arguments, CmdProvider cmdProvider, boolean preview, Commons.ActionResult actionResult, AdbDevice device, List<String> allPackages) {
        List<String> filteredPackages = new PackageMatcher(allPackages).findMatches(arguments.mainArgument);

        if (arguments.mode == Arg.Mode.START_ACTIVITY || arguments.mode == Arg.Mode.FORCE_STOP) {
            Commons.runAdbCommand(new String[]{"-s", device.serial, "shell", "input", "keyevent", "KEYCODE_WAKEUP"}, cmdProvider, adbLocation);

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method equals has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

Severity: Minor
Found in src/main/java/at/favre/tools/uberadb/ui/Arg.java - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method create has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public static void create(AdbLocationFinder.LocationResult adbLocation, Arg arguments, CmdProvider cmdProvider, AdbDevice device, List<String> allPackages) throws Exception {
        Commons.logLoud("create bug report:");

        String dateTimeString = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss-SSS").format(new Date());

Severity: Minor
Found in src/main/java/at/favre/tools/uberadb/actions/BugReport.java - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method equals has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

Severity: Minor
Found in src/main/java/at/favre/tools/uberadb/parser/DumpsysPackageParser.java - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method parse has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static Arg parse(String[] args) {
        Options options = setupOptions();
        CommandLineParser parser = new DefaultParser();
        Arg argument = new Arg();

Severity: Major
Found in src/main/java/at/favre/tools/uberadb/ui/CLIParser.java - About 3 hrs to fix

    Method create has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static void create(AdbLocationFinder.LocationResult adbLocation, Arg arguments, CmdProvider cmdProvider, AdbDevice device, List<String> allPackages) throws Exception {
            Commons.logLoud("create bug report:");
    
            String dateTimeString = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss-SSS").format(new Date());
    
    
    Severity: Major
    Found in src/main/java/at/favre/tools/uberadb/actions/BugReport.java - About 3 hrs to fix

      Method parse has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public static Arg parse(String[] args) {
              Options options = setupOptions();
              CommandLineParser parser = new DefaultParser();
              Arg argument = new Arg();
      
      
      Severity: Minor
      Found in src/main/java/at/favre/tools/uberadb/ui/CLIParser.java - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method checkAndGetFromPATHEnvVar has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public static File checkAndGetFromPATHEnvVar(CmdProvider provider, final String matchesExecutable) {
              String pathEnv = System.getenv("PATH");
              if (pathEnv != null) {
                  String[] pathParts = pathEnv.split(File.pathSeparator);
                  for (String pathPart : pathParts) {
      Severity: Minor
      Found in src/main/java/at/favre/tools/uberadb/util/CmdUtil.java - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method execute has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static Commons.ActionResult execute(Arg arguments, CmdProvider cmdProvider, AdbLocationFinder locationFinder, UserPromptHandler promptHandler) {
              Commons.ActionResult result = null;
      
              try {
                  AdbLocationFinder.LocationResult adbLocation = locationFinder.find(cmdProvider, arguments.adbPath);
      Severity: Major
      Found in src/main/java/at/favre/tools/uberadb/AdbTool.java - About 2 hrs to fix

        Method setupOptions has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static Options setupOptions() {
                Options options = new Options();
        
                Option mainInstall = Option.builder(ARG_INSTALL).longOpt("install").argName("apk file/folder").desc("Provide path to an " +
                        "apk file or folder containing apk files and the tool tries to install all of them to all connected devices (if not" +
        Severity: Major
        Found in src/main/java/at/favre/tools/uberadb/ui/CLIParser.java - About 2 hrs to fix

          Method iterateDevices has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static Commons.IterationResult iterateDevices(List<AdbDevice> devices, AdbLocationFinder.LocationResult adbLocation, Arg arguments,
                                                                    CmdProvider cmdProvider, UserPromptHandler promptHandler, boolean preview) throws Exception {
                  Commons.ActionResult actionResult = new Commons.ActionResult();
          
                  if (preview && (arguments.dryRun || arguments.force || arguments.mode == Arg.Mode.BUGREPORT || arguments.mode == Arg.Mode.FORCE_STOP
          Severity: Major
          Found in src/main/java/at/favre/tools/uberadb/AdbTool.java - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                    if (preview && (arguments.dryRun || arguments.force || arguments.mode == Arg.Mode.BUGREPORT || arguments.mode == Arg.Mode.FORCE_STOP
                            || arguments.mode == Arg.Mode.INFO || arguments.mode == Arg.Mode.START_ACTIVITY
                            || (arguments.mode == Arg.Mode.INSTALL && devices.size() == 1 && Install.isSingleFile(arguments)))) {
                        return new Commons.IterationResult(actionResult, true);
                    }
            Severity: Critical
            Found in src/main/java/at/favre/tools/uberadb/AdbTool.java - About 2 hrs to fix

              Method equals has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  @Override
                  public boolean equals(Object o) {
                      if (this == o) return true;
                      if (o == null || getClass() != o.getClass()) return false;
              
              
              Severity: Minor
              Found in src/main/java/at/favre/tools/uberadb/parser/AdbDevice.java - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method parseAndSortUniqueFilesNonRecursive has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public List<File> parseAndSortUniqueFilesNonRecursive(String[] files, String extensionFilter) {
                      if (files == null) {
                          throw new IllegalArgumentException("input files must not be null");
                      }
              
              
              Severity: Minor
              Found in src/main/java/at/favre/tools/uberadb/ui/FileArgParser.java - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method execute has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static void execute(AdbLocationFinder.LocationResult adbLocation, Arg arguments, CmdProvider cmdProvider, boolean preview, Commons.ActionResult actionResult, AdbDevice device, List<String> allPackages) {
                      List<String> filteredPackages = new PackageMatcher(allPackages).findMatches(arguments.mainArgument);
              
                      if (arguments.mode == Arg.Mode.START_ACTIVITY || arguments.mode == Arg.Mode.FORCE_STOP) {
                          Commons.runAdbCommand(new String[]{"-s", device.serial, "shell", "input", "keyevent", "KEYCODE_WAKEUP"}, cmdProvider, adbLocation);

                Method execute has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static void execute(AdbLocationFinder.LocationResult adbLocation, Arg arguments, CmdProvider cmdProvider, boolean preview, Commons.ActionResult actionResult, AdbDevice device) {
                        List<File> installFiles = new FileArgParser().parseAndSortUniqueFilesNonRecursive(arguments.mainArgument, EXTENSION_APK);
                
                        if (installFiles.isEmpty()) {
                            throw new IllegalStateException("could not find any apk files in " + Arrays.toString(arguments.mainArgument) + " to install");
                Severity: Minor
                Found in src/main/java/at/favre/tools/uberadb/actions/Install.java - About 1 hr to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Severity
                Category
                Status
                Source
                Language