GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • CodeQL documentation
  • CodeQL overview
  • Writing CodeQL queries
  • CodeQL language guides
  • QL language reference
  • CodeQL standard-libraries
  • CodeQL query help
  • CodeQL repository
  • QL publications
  • CodeQL query help for C and C++
  • CodeQL query help for C#
  • CodeQL query help for GitHub Actions
  • CodeQL query help for Go
  • CodeQL query help for Java and Kotlin

This view

  • Original page
  • New address

GeezerVison is showing codeql.github.com — Redundant assignment — CodeQL query help documentation

Redundant assignment¶

ID: py/redundant-assignment
Kind: problem
Security severity: 
Severity: error
Precision: very-high
Tags:
   - quality
   - reliability
   - correctness
   - external/cwe/cwe-563
Query suites:
   - python-code-quality.qls
   - python-security-and-quality.qls

Click to see the query in the CodeQL repository

Assigning a variable to itself is redundant and often an indication of a mistake in the code.

Recommendation¶

Check the assignment carefully for mistakes. If the assignment is truly redundant and not simply incorrect then remove it.

Example¶

In this example the programmer clearly intends to assign to self.eggs but made a mistake.

class Spam:

    def __init__(self, eggs):
        eggs = eggs

References¶

  • Python Language Reference: The assignment statement.

  • Common Weakness Enumeration: CWE-563.

  • © GitHub, Inc.
  • Terms
  • Privacy
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.