bykovme/nswallet

View on GitHub
src/NSWallet/Droid/Interfaces/FileService.cs

Summary

Maintainability
D
1 day
Test Coverage

Class FileService has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

    public class FileService : IFile
    {
        const string OLD_DROID_FILEPATH = "/app_nswallet/nswallet.dat";
        const string OLD_DROID_DIRPATH = "/app_nswallet";

Severity: Minor
Found in src/NSWallet/Droid/Interfaces/FileService.cs - About 2 hrs to fix

    File FileService.cs has 267 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    using NSWallet.Droid;
    using Xamarin.Forms;
    using NSWallet.Shared;
    using System.IO;
    using System.IO.Compression;
    Severity: Minor
    Found in src/NSWallet/Droid/Interfaces/FileService.cs - About 2 hrs to fix

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

              public List<string> ReadZip(string path)
              {
                  try {
                      var zip = ZipFile.OpenRead(path);
                      var entries = new List<string>();
      Severity: Major
      Found in src/NSWallet/Droid/Interfaces/FileService.cs and 2 other locations - About 1 hr to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 147..164
      src/NSWallet/iOS/Interfaces/FileService.cs on lines 175..198

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 141.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              public IEnumerable<string> GetFilePaths(string path)
              {
                  try {
                      return Directory.EnumerateFiles(path);
                  } catch (DirectoryNotFoundException ex) {
      Severity: Minor
      Found in src/NSWallet/Droid/Interfaces/FileService.cs and 1 other location - About 55 mins to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 59..68

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 87.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

              public string ReadFromFile(string path)
              {
                  try {
                      using (var streamReader = new StreamReader(path)) {
                          string content = streamReader.ReadToEnd();
      Severity: Major
      Found in src/NSWallet/Droid/Interfaces/FileService.cs and 2 other locations - About 55 mins to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 134..145
      src/NSWallet/iOS/Interfaces/FileService.cs on lines 162..173

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 85.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

              public void WriteInFile(string path, string content)
              {
                  try {
                      using (var streamWriter = new StreamWriter(path, false)) {
                          streamWriter.WriteLine(content);
      Severity: Major
      Found in src/NSWallet/Droid/Interfaces/FileService.cs and 2 other locations - About 50 mins to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 123..132
      src/NSWallet/iOS/Interfaces/FileService.cs on lines 151..160

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 82.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

              public long GetFileSize(string path)
              {
                  try {
                      var fi = new FileInfo(path);
                      return fi.Length;
      Severity: Major
      Found in src/NSWallet/Droid/Interfaces/FileService.cs and 2 other locations - About 40 mins to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 75..84
      src/NSWallet/iOS/Interfaces/FileService.cs on lines 89..98

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 72.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              public void CopyFile(string srcFilename, string destFilename)
              {
                  try {
                      System.IO.File.Copy(srcFilename, destFilename);
                  } catch (Exception ex) {
      Severity: Minor
      Found in src/NSWallet/Droid/Interfaces/FileService.cs and 1 other location - About 40 mins to fix
      src/NSWallet/Droid/Interfaces/FileService.cs on lines 144..151

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 69.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              public void MoveFile(string pathFrom, string pathTo)
              {
                  try {
                      System.IO.File.Move(pathFrom, pathTo);
                  } catch (Exception ex) {
      Severity: Minor
      Found in src/NSWallet/Droid/Interfaces/FileService.cs and 1 other location - About 40 mins to fix
      src/NSWallet/Droid/Interfaces/FileService.cs on lines 253..260

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 69.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

              public bool RemoveDirectoryWithContents(string path)
              {
                  try {
                      Directory.Delete(path, true);
                      return true;
      Severity: Minor
      Found in src/NSWallet/Droid/Interfaces/FileService.cs and 2 other locations - About 35 mins to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 199..208
      src/NSWallet/iOS/Interfaces/FileService.cs on lines 250..262

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 66.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              public void CreateFile(string path)
              {
                  try {
                      System.IO.File.Create(path);
                  } catch (Exception ex) {
      Severity: Minor
      Found in src/NSWallet/Droid/Interfaces/FileService.cs and 1 other location - About 35 mins to fix
      src/NSWallet/Droid/Interfaces/FileService.cs on lines 153..160

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 63.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              public void RemoveFile(string path)
              {
                  try {
                      System.IO.File.Delete(path);
                  } catch (Exception ex) {
      Severity: Minor
      Found in src/NSWallet/Droid/Interfaces/FileService.cs and 1 other location - About 35 mins to fix
      src/NSWallet/Droid/Interfaces/FileService.cs on lines 162..169

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 63.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

                  if (RequestPermissionsManager.ReadWriteStoragePermission() == true) {
                      try {
                          ZipFile.ExtractToDirectory(pathFrom, pathTo, true);
                          return true;
                      } catch (Exception ex) {
      Severity: Minor
      Found in src/NSWallet/Droid/Interfaces/FileService.cs and 1 other location - About 30 mins to fix
      src/NSWallet/iOS/Interfaces/FileService.cs on lines 201..211

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 61.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status