TsundokuApp/Tsundoku

View on GitHub

Showing 27 of 27 total issues

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

  async unregister() {
    const loader = this.loadingCtrl.create({
      content: '削除処理中です…'
    });
    loader.present();
Severity: Major
Found in client/src/pages/book-details-modal/book-details-modal.ts and 1 other location - About 5 hrs to fix
client/src/pages/book-details-modal/book-details-modal.ts on lines 95..110

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

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

  async register() {
    const loader = this.loadingCtrl.create({
      content: '追加処理中です…'
    });
    loader.present();
Severity: Major
Found in client/src/pages/book-details-modal/book-details-modal.ts and 1 other location - About 5 hrs to fix
client/src/pages/book-details-modal/book-details-modal.ts on lines 186..201

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

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

Function searchBook has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async searchBook(isbn: string) {
    const loader = this.loadingCtrl.create({
      content: '検索中です…'
    });
    loader.present();
Severity: Major
Found in client/src/pages/bookshelf/bookshelf.ts - About 2 hrs to fix

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

      registerBook = (isbn: string): Promise<void> =>
        this.afFunctions
          .httpsCallable('registerBook')({
            isbn,
            uid: (firebase.auth().currentUser as firebase.User).uid
    Severity: Major
    Found in client/src/app/services/bookshelf.service.ts and 1 other location - About 2 hrs to fix
    client/src/app/services/bookshelf.service.ts on lines 45..51

    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

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

      unregisterBook = async (isbn: string): Promise<void> =>
        this.afFunctions
          .httpsCallable('unregisterBook')({
            isbn,
            uid: (firebase.auth().currentUser as firebase.User).uid
    Severity: Major
    Found in client/src/app/services/bookshelf.service.ts and 1 other location - About 2 hrs to fix
    client/src/app/services/bookshelf.service.ts on lines 37..43

    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

    Function constructor has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor(
        private navParams: NavParams,
        private loadingCtrl: LoadingController,
        protected viewCtrl: ViewController,
        protected toastCtrl: ToastController,
    Severity: Minor
    Found in client/src/pages/book-details-modal/book-details-modal.ts - About 1 hr to fix

      Function createPlan has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        createPlan() {
          this.alertCtrl
            .create({
              title: '読書計画の追加',
              message: '計画のタイトルと説明文を入力してください',
      Severity: Minor
      Found in client/src/pages/book-details-modal/book-details-modal.ts - About 1 hr to fix

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

            case BookshelfActionTypes.UpdateBookshelf:
              const books = (action as UpdateBookshelf).payload;
              sortByDatetime({ key: 'modified', objects: books }, 'desc');
              return Object.assign({}, { ...state, books });
        Severity: Major
        Found in client/src/app/state/bookshelf/bookshelf.reducer.ts and 1 other location - About 1 hr to fix
        client/src/app/state/skill/skill.reducer.ts on lines 13..16

        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

            case SkillActionTypes.UpdateSkill:
              const skills = (action as UpdateSkill).payload;
              sortByDatetime({ key: 'created', objects: skills }, 'desc');
              return Object.assign({}, { ...state, skills });
        Severity: Major
        Found in client/src/app/state/skill/skill.reducer.ts and 1 other location - About 1 hr to fix
        client/src/app/state/bookshelf/bookshelf.reducer.ts on lines 16..19

        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

        Function ionViewDidLoad has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          ionViewDidLoad() {
            this.store.dispatch(new WatchSkill());
            this.skills$ = this.store.pipe(
              select(getSkills),
              map(skills => {
        Severity: Minor
        Found in client/src/pages/achievement/achievement.ts - About 1 hr to fix

          Function searchBookListener has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            searchBookListener() {
              this.alertCtrl
                .create({
                  title: 'ISBN で本を検索',
                  inputs: [
          Severity: Minor
          Found in client/src/pages/bookshelf/bookshelf.ts - About 1 hr to fix

            Function update has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async update() {
                if (this.valid === false) return;
                let count = parseInt(this.pageCount, 10);
                if (count < 0) count = 0;
                if (count > this.plan.book.pageCount) {

              Function createSkillListener has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                createSkillListener() {
                  this.alertCtrl
                    .create({
                      title: 'スキルの追加',
                      inputs: [

                Function ngAfterViewInit has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  ngAfterViewInit() {
                    const context = this.graph.nativeElement.getContext('2d');
                    new Chart(context, {
                      type: 'doughnut',
                      data: {
                Severity: Minor
                Found in client/src/pages/progress/progress-card/progress-card.ts - About 1 hr to fix

                  Function adjustThumbnails has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    adjustThumbnails() {
                      const firstThumbnail = document.getElementsByClassName('book-thumbnail')[0];
                      if (firstThumbnail === void 0) return;
                  
                      const booksRow = document.getElementById('books-row'),
                  Severity: Minor
                  Found in client/src/pages/bookshelf/bookshelf.ts - About 1 hr to fix

                    Function skills$ has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          map(skills => {
                            this.labels = [];
                            this.data = [];
                            let sum = 0;
                            const dateWithSum = {};
                    Severity: Minor
                    Found in client/src/pages/achievement/achievement.ts - About 1 hr to fix

                      Function sortFn has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const sortFn = (fieldName: string, order: Order) => (
                        former,
                        latter
                      ): number => {
                        const asc = order === 'asc',
                      Severity: Minor
                      Found in client/src/app/services/firestore-utils.ts - About 55 mins 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

                      Function searchBook has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        async searchBook(isbn: string) {
                          const loader = this.loadingCtrl.create({
                            content: '検索中です…'
                          });
                          loader.present();
                      Severity: Minor
                      Found in client/src/pages/bookshelf/bookshelf.ts - About 55 mins 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

                      Function ionViewDidLoad has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        ionViewDidLoad() {
                          this.store.dispatch(new WatchSkill());
                          this.skills$ = this.store.pipe(
                            select(getSkills),
                            map(skills => {
                      Severity: Minor
                      Found in client/src/pages/achievement/achievement.ts - About 45 mins 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

                      Function _deleteSkill has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export const _deleteSkill = (db: FirebaseFirestore.Firestore) => async (args: {
                        isbn: string;
                        content: string;
                        uid: string;
                      }) => {
                      Severity: Minor
                      Found in functions/src/skill.ts - About 45 mins 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