stylist.fortran — Stylist 0.3.dev1 documentation

# stylist.fortran

Rules relating to Fortran source.

Classes

`AutoCharArrayIntent`() | Checks that all automatically assigned character arrays used as subroutine or function arguments have intent(in) to avoid writing outside the given array.
`FortranCharacterset`() | Traps any characters which do not fall in the list of those allowed in Fortran source.
`FortranRule`() | Parent for style rules pertaining to Fortran source.
`IntrinsicModule`() | Catches cases where an intrinsic module is used with the "intrinsic" keyword ommitted.
`KindPattern`(*, integer, real) | Ensures kind names match a specified pattern.
`LabelledDoExit`() | Catches cases where a "do" construct is exited but not explicitly named.
`MissingImplicit`([require_everywhere]) | Catches cases where code blocks which could have an `implicit` statement don't.
`MissingIntent`() | Catches cases where a function or subroutine's dummy arguments don't have specified intent.
`MissingOnly`([ignore]) | Catches cases where a "use" statement is present but has no "only" clause.
`MissingPointerInit`() | Catches cases where a pointer is declared without being initialised.

class stylist.fortran.AutoCharArrayIntent

  Bases: `stylist.fortran.FortranRule`

  Checks that all automatically assigned character arrays used as subroutine or function arguments have intent(in) to avoid writing outside the given array.

  examine_fortran(subject)

    Examines the provided Fortran source code object for an issue.

    Parameters

      subject (`FortranSource`) – Source file to examine.

    Return type

      `List`[`Issue`]

    Returns

      Issues found with the source.

class stylist.fortran.FortranCharacterset

  Bases: `stylist.rule.Rule`

  Traps any characters which do not fall in the list of those allowed in Fortran source. This takes into account the fact that there is no restriction on what may appear in comments or strings.

  examine(subject)

    Examines the provided source code object for issues.

    Parameters

      subject (`FortranSource`) – The source file to be examined.

    Return type

      `List`[`Issue`]

    Returns

      All issues found with the source.

class stylist.fortran.FortranRule

  Bases: `stylist.rule.Rule`

  Parent for style rules pertaining to Fortran source.

  examine(subject)

    Base for rules which scruitinise the parse tree of Fortran source.

    Parameters

      subject (`FortranSource`) – Source file to examine.

    Return type

      `List`[`Issue`]

    Returns

      Issues found with the source.

  abstract examine_fortran(subject)

    Examines the provided Fortran source code object for an issue.

    Parameters

      subject (`FortranSource`) – Source file to examine.

    Return type

      `List`[`Issue`]

    Returns

      Issues found with the source.

class stylist.fortran.IntrinsicModule

  Bases: `stylist.fortran.FortranRule`

  Catches cases where an intrinsic module is used with the “intrinsic” keyword ommitted.

  examine_fortran(subject)

    Examines the provided Fortran source code object for an issue.

    Parameters

      subject (`FortranSource`) – Source file to examine.

    Return type

      `List`[`Issue`]

    Returns

      Issues found with the source.

class stylist.fortran.KindPattern(*, integer, real)

  Bases: `stylist.fortran.FortranRule`

  Ensures kind names match a specified pattern.

  Patterns are set only for integer and real data types however Fortran supports many more. Logical and Complex for example. For those cases a default pattern of “.*” is used to accept anything.

  Parameters

    - integer (`Union`[`str`, `Pattern`]) – Regular expression which integer kinds must match.

    - real (`Union`[`str`, `Pattern`]) – Regular expression which real kinds must match.

  examine_fortran(subject)

    Examines the provided Fortran source code object for an issue.

    Parameters

      subject (`FortranSource`) – Source file to examine.

    Return type

      `List`[`Issue`]

    Returns

      Issues found with the source.

class stylist.fortran.LabelledDoExit

  Bases: `stylist.fortran.FortranRule`

  Catches cases where a “do” construct is exited but not explicitly named.

  examine_fortran(subject)

    Examines the provided Fortran source code object for an issue.

    Parameters

      subject (`FortranSource`) – Source file to examine.

    Return type

      `List`[`Issue`]

    Returns

      Issues found with the source.

class stylist.fortran.MissingImplicit(require_everywhere=False)

  Bases: `stylist.fortran.FortranRule`

  Catches cases where code blocks which could have an `implicit` statement don’t.

  Parameters

    require_everywhere (`Optional`[`bool`]) – By default the rule checks only in places which require an `implicit` statement. Set this argument to check everywhere an `implicit` could exist.

  examine_fortran(subject)

    Examines the provided Fortran source code object for an issue.

    Parameters

      subject (`FortranSource`) – Source file to examine.

    Return type

      `List`[`Issue`]

    Returns

      Issues found with the source.

class stylist.fortran.MissingIntent

  Bases: `stylist.fortran.FortranRule`

  Catches cases where a function or subroutine’s dummy arguments don’t have specified intent.

  examine_fortran(subject)

    Examines the provided Fortran source code object for an issue.

    Parameters

      subject (`FortranSource`) – Source file to examine.

    Return type

      `List`[`Issue`]

    Returns

      Issues found with the source.

class stylist.fortran.MissingOnly(ignore=None)

  Bases: `stylist.fortran.FortranRule`

  Catches cases where a “use” statement is present but has no “only” clause.

  Parameters

    ignore (`Optional`[`List`[`str`]]) – List of module names which are not required to have an “only” clause.

  examine_fortran(subject)

    Examines the provided Fortran source code object for an issue.

    Parameters

      subject (`FortranSource`) – Source file to examine.

    Return type

      `List`[`Issue`]

    Returns

      Issues found with the source.

class stylist.fortran.MissingPointerInit

  Bases: `stylist.fortran.FortranRule`

  Catches cases where a pointer is declared without being initialised.

  examine_fortran(subject)

    Examines the provided Fortran source code object for an issue.

    Parameters

      subject (`FortranSource`) – Source file to examine.

    Return type

      `List`[`Issue`]

    Returns

      Issues found with the source.