Occasion of sin
In Christian hamartiology, occasions of sin are "external circumstances—whether of things or persons—that either, due to their special nature or because of the frailty common to humanity or particular to some individual, incite or entice one to sin." This Christian theological concept is taught in the Roman Catholic, Lutheran, and Reformed traditions. History 
The obligation to avoid near occasions of sin can be traced back to the evangelical counsel formulated in the first Epistle of Saint Peter warning to "keep watch" as "the devil goes about seeking whom he may devor." (1 Pet. 5.8)

On the opposite side, another spiritual tradition of confronting the devil's temptation can be traced back to Jesus going to the desert "to be tempted" (Luke 4:1–13; Matthew 4:1–11). The cenobitic tradition of the Desert Fathers lived out this spiritual warfare by voluntarily facing temptations. "Tempting the devil" went as far as to develop the practise of syneisaktism for which Robert of Arbrissel, itinerant preacher, and founder of Fontevraud Abbey in the 11th century, was most notorious for. The council of Poitiers in November 1100 which two legates of Pope Paschal II had convened earlier that same year condemned this practise. Beyond detailing the importance of the cardinal virtue of prudence in his Summa Theologiae, Saint Thomas Aquinas has been seen as a model in fleeing the near occasions of sin since the 13th century. For the famous episode of him fleeing the women sent to him by his brothers and given a chastity chord by angels, he was said to have fled these worldly temptations, "fuggendo le occasioni", like men run away from serpents and scorpions. The formula of "avoiding occasions of sin" is first found in Latin in the writings of Bernardino of Siena  for whom it is the best of all counsels, and as it were "the foundation of religion":  

In the 14th century, Matthew of Kraków makes it clear that a confession is fully made only when the occasions and causes of sins are also mentioned:

The development of Christian hamartiology and the necessity to commit to avoidance of near occasions of sin is illustrated in Christian iconography around the 15th century, by the legend surrounding the Cristo de la Mano Tendida ("Christ with an extended hand") in the parrochial church of San Xoán de Furelos on the Camino de Santiago. These crucifixes represent Christ on the Cross from which one hand is set free to reach out to the faithful praying. According to local traditions, in 1512, a penant who was refused absolution for his sin after being incapable of avoiding near occasions of sin saw Christ on the Crucifix extend a helpful hand to him in sign of his mercy. Alphonsus Liguori, as he expanded on the moral aspects of confessions in the 18th century, is the one who provided the universal Church with the most systematic doctrine of the proximate occasion of sin. The doctrine of occasion of sin tended to rigidify and in reaction, certain theologians tried to offer of more open-minded approach to the doctrine through a return to early Christianity. Thus, in 1948, Jesuist Cardinal Jean Danielou, quoting Origen, asserted that not every occasion of sin necessarily results in sin. However, the latter "died in disgrace. In 1974, at age sixty-nine, [he was] found dead in the home of a Parisian prostitute." Though explanations and excuses were provided, others believed his presence in a brothel to be a proximate occasion of sin which should have been avoided. The doctrine of occasions of sin was still expanded upon by some preachers in the wake of the Second Vatican Council such as don Giuseppe Tomaselli in the 1960s while to many it may now sound "corny and outdated". It was used as a cornerstone by Saint John Paul II in his encyclical on the sacrament of reconciliation, Reconciliatio et Paenitentia, to explain the structures of sin, which are a further development of the doctrine of the near occasions of sin. According to the official Vatican website, near occasions of sin are to be rejected before receiving absolution in one of the forms of the act of contrition. In 2018, Bishop Thomas Joseph Tobin caused a mediatic roar by leaving Twitter and calling it an "occasion of sin", even though, according to the Catholic prelate, "the secular world might not be familiar with the concept". Definition 
The occasion of sin can be proximate or remote, exterior or interior, voluntary or necessary. Proximate or remote 
A proximate occasion is one in which men of like calibre for the most part fall into mortal sin, or one in which experience points to the same result from the special weakness of a particular person. A proximate occasion of sin can be in se or per accidens. There is a debate between laxists and rigorists as to whether an occasion of sin is one which leads to sin systematically, occasionally or even just potentially. Thus, Catholic bishop Jean-Joseph Gaume argued that there is a proximate occasion of sin in "every occasion that leads to sin". It remains to casuists to determine some cases where opinions may differ. For example, while it is not a general opinion, some traditional Catholic congregations such as the Society of Saint Pius X oppose the presence of television in the household, teaching that it is an occasion of sin. The occasion in se is one which leads to sin by its nature, such as gambling or obscenity, while the occasion per accidens is in by which the human weakness of some people in particular may lead to sin, such as military professions, legal professions, binge drinking, and artistic professions. The remote occasion lacks these elements. All theologians are agreed that there is no obligation to avoid the remote occasions of sin both because this would, practically speaking, be impossible and because they do not involve serious danger of sin. Exterior or interior 
An interior occasion is an occasion of sin that is carried inside every soul and which can be a bad habit, an inclination to anger or to pride. An exterior occasion of sin is an occasion of sin that comes from worldly temptations related to a certain time and place. Necessary or voluntary 
The proximate occasion may be necessary, that is, such as a person cannot abandon or get rid of. Whether this impossibility be physical or moral does not matter for the determination of the principles hereinafter to be laid down. A proximate occasion may be deemed necessary when it cannot be given up without grave scandal or loss of good name or without notable temporal or spiritual damage. It may be voluntary, within the competency of one to remove. Moralists distinguish between a proximate occasion which is continuous and one which, whilst it is unquestionably proximate, yet confronts a person only at intervals. Someone who is in the presence of a proximate occasion at once voluntary and continuous is bound to remove it. In confession, a refusal on the part of a penitent to do so would make it imperative for the confessor to deny absolution. It is not always necessary for the confessor to await the actual performance of this duty before giving absolution; he may be content with a sincere promise, which is the minimum to be required. Analysis 
In root cause analysis the occasion of sin is identical to the idea of "set-up factors", i.e. situations in which it is likely for a person to perform dysfunctionally. In the nuclear industry community there is a set of ideas called "Event Free tools" that includes the idea of avoiding "Error Likely Situations", which are also called "Human Error Precursors." In social counseling there is the acronymic advice, HALT (Hungry? Angry? Lonely? Tired?) relating to situations in which judgment is impaired. These may be regarded as "occasions of sin." See also

Abstinence pledge
Confraternities of the Cord
Mortification of the flesh
Purity ring
Sacramentals
Temperance movement
Teetotalism

References

External links
Catholic Encyclopedia "Occasions of Sin"

Christian ethics
Christian hamartiology
Catholic moral theology