Showing 1,485 of 1,485 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (const cell of cells) {
rowSize += cell.getColSpan() || 1;
if (cell.getRowSpan() > 1) {
throw Error('Cannot copy rows with merged cells');
}
- Read upRead up
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 56.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method validateTokenClaims
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function validateTokenClaims(string $clientId): void
{
// 1. The Issuer Identifier for the OpenID Provider (which is typically obtained during Discovery)
// MUST exactly match the value of the iss (issuer) Claim.
// Already done in parent.
Function setupListeners
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
setupListeners() {
const navHandler = new KeyboardNavigationHandler(
this.list,
() => {
this.input.focus();
Function saveComment
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
saveComment(event) {
event.preventDefault();
event.stopPropagation();
const loading = getLoading();
Method store
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function store(Request $request)
{
$this->checkPermission('users-manage');
$authMethod = config('auth.method');
Function createDomForFile
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
createDomForFile(file) {
const image = elem('img', {src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.224 7.373a.924.924 0 0 0-.92.925l-.006 7.404c0 .509.412.925.921.925h5.557a.928.928 0 0 0 .926-.925v-5.553l-2.777-2.776Zm3.239 3.239V8.067l2.545 2.545z' style='fill:%23000;fill-opacity:.75'/%3E%3C/svg%3E"});
const status = elem('div', {class: 'dropzone-file-item-status'}, []);
const progress = elem('div', {class: 'dropzone-file-item-progress'});
const imageWrap = elem('div', {class: 'dropzone-file-item-image-wrap'}, [image]);
Function paste
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function paste(editor, options, event) {
const clipboard = new Clipboard(event.clipboardData || event.dataTransfer);
// Don't handle the event ourselves if no items exist of contains table-looking data
if (!clipboard.hasItems() || clipboard.containsTabularData()) {
Method createManyJointPermissions
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function createManyJointPermissions(array $originalEntities, array $roles)
{
$entities = $this->entitiesToSimpleEntities($originalEntities);
$jointPermissions = [];
Function setup
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
setup() {
// Options
this.uploadedTo = this.$opts.uploadedTo;
// Element References
Method attempt
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function attempt(array $credentials = [], $remember = false)
{
$username = $credentials['username'];
$userDetails = $this->ldapService->getUserDetails($username);
Function wrapContinuousInlines
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wrapContinuousInlines(
domNode: Node,
nodes: Array<LexicalNode>,
createWrapperFn: () => ElementNode,
): Array<LexicalNode> {
Function importDOM
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static importDOM(): DOMConversionMap | null {
return {
h1: (node: Node) => ({
conversion: $convertHeadingElement,
priority: 0,
Function action
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async action(formData, context: EditorUiContext) {
context.editor.update(() => {
const table = $getTableFromSelection($getSelection());
if (!table) {
return;
Method show
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function show(Request $request, ActivityQueries $activities, string $slug)
{
$shelf = $this->queries->findVisibleBySlugOrFail($slug);
$this->checkOwnablePermission('bookshelf-view', $shelf);
Function forChild
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
forChild: (lexicalNode, parentLexicalNode) => {
if ($isTableCellNode(parentLexicalNode) && !$isElementNode(lexicalNode)) {
const paragraphNode = $createParagraphNode();
if (
$isLineBreakNode(lexicalNode) &&
Function getLastTextNode
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getLastTextNode(startingNode: Node) {
let node = startingNode;
mainLoop: while (node !== null) {
if (node !== startingNode && node.nodeType === 3) {
Function getNextTextNode
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getNextTextNode(startingNode: Node) {
let node = startingNode;
mainLoop: while (node !== null) {
if (node !== startingNode && node.nodeType === 3) {
Function forChild
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
forChild: (lexicalNode, parentLexicalNode) => {
if ($isTableCellNode(parentLexicalNode) && !$isElementNode(lexicalNode)) {
const paragraphNode = $createParagraphNode();
if (
$isLineBreakNode(lexicalNode) &&
Function choice
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
choice(translation: string, count: number, replacements: Record<string, string> = {}): string {
const splitText = translation.split('|');
const exactCountRegex = /^{([0-9]+)}/;
const rangeRegex = /^\[([0-9]+),([0-9*]+)]/;
let result = null;
Function $parseSerializedNodeImpl
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function $parseSerializedNodeImpl<
SerializedNode extends InternalSerializedNode,
>(
serializedNode: SerializedNode,
registeredNodes: RegisteredNodes,