bykovme/nswallet

View on GitHub
src/NSWallet/iOS/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 DATABASE_IOS_FOLDER = @"/.nsw/nswallet";

        public string CheckOldFile()
Severity: Minor
Found in src/NSWallet/iOS/Interfaces/FileService.cs - About 2 hrs to fix

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

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

      FIXME found
      Open

                  return ""; // FIXME

      FIXME found
      Open

                  return GetInternalDirPath(); // FIXME

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

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

      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 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/iOS/Interfaces/FileService.cs and 2 other locations - About 55 mins to fix
      src/NSWallet/Droid/Interfaces/FileService.cs on lines 182..193
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 134..145

      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/iOS/Interfaces/FileService.cs and 2 other locations - About 50 mins to fix
      src/NSWallet/Droid/Interfaces/FileService.cs on lines 171..180
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 123..132

      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 2 locations. Consider refactoring.
      Open

              public bool CreateZip(string pathSourceFolder, string pathDestinationFolder, string fileName)
              {
                  try
                  {
                      ZipFile.CreateFromDirectory(pathSourceFolder, pathDestinationFolder + "/" + fileName);
      Severity: Minor
      Found in src/NSWallet/iOS/Interfaces/FileService.cs and 1 other location - About 50 mins to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 177..186

      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 78.

      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 byte[] GetBytesFromFile(string path)
              {
                  try
                  {
                      var bytes = File.ReadAllBytes(path);
      Severity: Minor
      Found in src/NSWallet/iOS/Interfaces/FileService.cs and 1 other location - About 45 mins to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 188..197

      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 75.

      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

                  try {
                      string dbFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + DATABASE_IOS_FOLDER;
      
                      if (!Directory.Exists(dbFolderPath)) {
                          Directory.CreateDirectory(dbFolderPath);
      Severity: Minor
      Found in src/NSWallet/iOS/Interfaces/FileService.cs and 1 other location - About 45 mins to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 33..41

      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 73.

      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/iOS/Interfaces/FileService.cs and 2 other locations - About 40 mins to fix
      src/NSWallet/Droid/Interfaces/FileService.cs on lines 123..132
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 75..84

      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

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

              public string GetInternalDirPath()
              {
                  string dbFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + DATABASE_IOS_FOLDER;
      
                  if (!Directory.Exists(dbFolderPath))
      Severity: Minor
      Found in src/NSWallet/iOS/Interfaces/FileService.cs and 1 other location - About 40 mins to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 43..52

      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 68.

      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 string GetTempFolder()
              {
                  try
                  {
                      var temp = NSFileManager.DefaultManager.GetTemporaryDirectory().Path;
      Severity: Minor
      Found in src/NSWallet/iOS/Interfaces/FileService.cs and 1 other location - About 40 mins to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 210..219

      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 68.

      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);
      Severity: Minor
      Found in src/NSWallet/iOS/Interfaces/FileService.cs and 2 other locations - About 35 mins to fix
      src/NSWallet/Droid/Interfaces/FileService.cs on lines 262..271
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 199..208

      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 3 locations. Consider refactoring.
      Open

              public void CopyFile(string srcFilename, string destFilename)
              {
                  try {
                      File.Copy(srcFilename, destFilename);
                  } catch (Exception ex) {
      Severity: Minor
      Found in src/NSWallet/iOS/Interfaces/FileService.cs and 2 other locations - About 35 mins to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 96..103
      src/NSWallet/iOS/Interfaces/FileService.cs on lines 124..131

      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 3 locations. Consider refactoring.
      Open

              public void MoveFile(string pathFrom, string pathTo)
              {
                  try {
                      File.Move(pathFrom, pathTo);
                  } catch (Exception ex) {
      Severity: Minor
      Found in src/NSWallet/iOS/Interfaces/FileService.cs and 2 other locations - About 35 mins to fix
      src/NSWallet/NSWallet.Mac/Interfaces/FileService.cs on lines 96..103
      src/NSWallet/iOS/Interfaces/FileService.cs on lines 241..248

      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

              {
                  try
                  {
                      ZipFile.ExtractToDirectory(pathFrom, pathTo, true);
                      return true;
      Severity: Minor
      Found in src/NSWallet/iOS/Interfaces/FileService.cs and 1 other location - About 30 mins to fix
      src/NSWallet/Droid/Interfaces/FileService.cs on lines 216..224

      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