| Total Complexity | 3 |
| Complexity/F | 1.5 |
| Lines of Code | 22 |
| Function Count | 2 |
| Duplicated Lines | 22 |
| Ratio | 100 % |
| Changes | 0 | ||
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | View Code Duplication | import { deleteRow } from 'prosemirror-tables'; |
|
|
|
|||
| 2 | import AbstractMenuItemDispatcher from './AbstractMenuItemDispatcher'; |
||
| 3 | import { svgIcon } from '../MDI'; |
||
| 4 | import MenuItem from '../MenuItem'; |
||
| 5 | |||
| 6 | export default class TRowDeleteMenuItemDispatcher extends AbstractMenuItemDispatcher { |
||
| 7 | static isAvailable(schema) { |
||
| 8 | return !!schema.nodes.table; |
||
| 9 | } |
||
| 10 | |||
| 11 | static getMenuItem(schema) { |
||
| 12 | if (!this.isAvailable(schema)) { |
||
| 13 | throw new Error('Table not available in schema!'); |
||
| 14 | } |
||
| 15 | |||
| 16 | return new MenuItem({ |
||
| 17 | command: deleteRow, |
||
| 18 | icon: svgIcon('table-row-remove'), |
||
| 19 | label: LANG.plugins.prosemirror['label:table-row-delete'], |
||
| 20 | }); |
||
| 21 | } |
||
| 22 | } |
||
| 23 |